Hello,
I have many @test methods which are getting parameters from a @dataProvider method .fine
i have a single @before method too which executes before each @test method as expected . fine
I can very well retrieve each @test method name during run time in my @before method using the java reflection -
java.lang.reflect.Method by just passing this in my before method arg list , some thing like below
@BeforeMethod()
public void startUpBeforeTestMethod(Method m)
{
String testName= m.getName();
}
But I am looking for retrieving the parameters list of my @Test method in the before method
can we get this
I have tried the same Reflection logic as below :
@BeforeMethod()
public void startUpBeforeTestMethod(Method m)
{
String testName= m.getName();
Method m2 =null;
Class class1 = getClass(); //this gives my currently running testclass where i have all my test methods
Method[] methods = class1.getMethods();
for (Method method : methods)
{
if(method.getName().equalsIgnoreCase(testName))
{
m2=method;
break;
}
}
Parameter[] parameters = m2.getParameters();
Parameter parameter = parameters[0]; //there is only one parameter that dataprovider supplies
}
but parameter variable do no hold any info about the actual parameters values that are provided by the dataProvider to the test method
please shed some light if you knows better logic
Warm Regards
Musafir