@BeforeMethod(alwaysRun = true)
public void beforeMethod(ITestContext context)
{
ITestNGMethod currentTestNGMethod = null;
for (ITestNGMethod testNGMethod : context.getAllTestMethods())
{
if (testNGMethod.getInstance() == this)
{
currentTestNGMethod = testNGMethod;
TestNG tng = new TestNG();
tng.setAnnotationTransformer(new MyTransformer(null, currentTestNGMethod.getRealClass(), null, null));
}
}
}
I've also tried using the ITestNGMethod as follows but it doesn't work either:
// Issue with the below when using both ITestAnnotation annotation,
// ITestContext context
// must be supplied as @Parameters or in @Configuration but googling says
// @Configuration is deprecated
@BeforeMethod(alwaysRun = true)
public void beforeMethod2(ITestContext context)
// ITestAnnotation annotation,
{
ITestNGMethod currentTestNGMethod = null;
System.out.println("============= TestNGMethod.class: " + ITestNGMethod.class);
for (ITestNGMethod testNGMethod : context.getAllTestMethods())
{
if (testNGMethod.getInstance() == this)
{
currentTestNGMethod = testNGMethod;
System.out.println("-------- currentTestNGMethod: " + currentTestNGMethod);
/////////////// doesn't work
currentTestNGMethod.setInvocationCount(getPositiveTestsToRun());
break;
}
}
System.out
.println("============= in @BeforeMethod of DriverBase positiveTestsToRun: " + getPositiveTestsToRun());
// TestNgListener.getTestMethod().setInvocationCount(getPositiveTestsToRun());
System.out.println("=== currentTestNGMethod.getInvocationCount(): " + currentTestNGMethod.getInvocationCount());
System.out.println("currentTestNGMethod.toString(): " + currentTestNGMethod.toString());
}
I've tried so many things to no avail. Any help would be appreciated!
Best regards,
Ann
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+unsubscribe@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.