How do I use IAnnotationTransformer in testNG? The code never stepped into the transform function when I debugged. It executed all 3 tests. I use Maven to trigger my tests, this is what I have--
public class SomeTest {
@BeforeClass
public void before(){
TestNG testNG = new TestNG();
testNG.setAnnotationTransformer(new Transformer());
}
@Test(priority = 1)
public void test1(){}
@Test(priority = 2)
public void test2(){}
@Test(priority = 3)
public void test3(){}
}
public class Transformer implements IAnnotationTransformer {
public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod){
if (true){
annotation.setEnabled(false);
}
}
}
Listeners are not automatically picked up until you have set them up using serviceloaders.
There are multiple ways to specify a listener, based on need.
If you do not want to apply them to all your tests, you may choose to apply a listener on a single class
eg.
@Listeners(Transformer.class)
public class InterceptorTC {
@Test(priority..
You can also specify a listener from maven surefire plugin. Read the using custom listener section here
Other ways to specify listener can be to define it in your suite xml and specify your suite xml file in the maven plugin.
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With