How to get the running method name

i am running the below test (settingsPasscodeSanity) & once “anotherfunction()” is called if it is failing i want to Know what is the method (in this case “settingsPasscodeSanity”) that called it (this will help me to better analyze my failures ).
is there a way where in the anotherfunction() i can store in a string the method that called it or the annotation parameters (e.g. description = “Settings: Passcode” ).


@Test(enabled = true, testName = “Sanity Tests”, description = “Settings: Passcode”,groups = { “Sanity Native iOS now” })
public void settingsPasscodeSanity() {
// anotherfunction();

using the “new Object(){}.getClass().getEnclosingMethod().getName()” function returns the current m

You might want to take a look at the Java Reflection API.

You can also check this link getting the name of the current executing method. There’s a method which you can use.