I want all my tests (let's say 100 tests, 1 per class) in several packages to run 3 times. I can set
@Test(invocationCount = SOME_CONSTANT)
But that would still require a hundred changes. Is there a way to set an invocationCount (or other params) in a single abstract class without resorting to adding this to every @Test
?
Build an annotation transformer implementation such as this
public class Transformer implements IAnnotationTransformer {
@Override
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
int someNumber = 100;
annotation.setInvocationCount(someNumber);
}
}
You then wire in this listener either using the <listener>
tag in the suite xml file (or) by creating the service loader file META-INF/services/org.testng.ITestNGListener
and then adding an entry for Transformer
into this file.
For more information on listeners you can take a look at this blog post of mine.