IAnnotationTransformer: Class level @Test annotoation causes "transform()" method invocation multiple times.
See original GitHub issueTestNG version - 7.5 Java version - 17.0.2 Build tool - Maven, surefire plugin version 3.0.0-M5 IDE -InteliJ
When @Test
annotation is set at class level and IAnnotationTransformer
interface is implemented, transform()
method gets invocated multiple times. I saw the same issue had been reported before and got fixed, but it appears again.
Here is my testng.xml
file content attached.
The Test Class
@Test
public class SomeTestClass {
public void someTest() {
System.out.println("someTest");
}
}
IAnnotationTransformer
implementation class
public class AnnotationTransformer implements IAnnotationTransformer {
@Override
public void transform(ITestAnnotation annotation, Class testClass,
Constructor testConstructor, Method testMethod) {
System.out.println(testClass);
}
}
And here is the output:
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
java - overridden transform method of IAnnotationTransformer ...
I used testng.xml to use listeners but invocation count is not changing. testng.xml.
Read more >Retry Failed Test in TestNG with IRetryAnalyzer
In the above scenario, test1 and test 2 re-runs 3 times and it fails during each execution. In the Retry class's retry method, ......
Read more >Test methods, classes and groups - TestNG Docs
In this class, method2() is part of the group "checkin-test", which is defined at the class level, while method1() belongs to both "checkin-test"...
Read more >TestNG Listeners In Selenium WebDriver With ... - LambdaTest
Class level : In this, you implement listeners for each particular class no ... This method is invoked each time the test method...
Read more >Documentation - TestNG
5 - Test methods, Test classes and Test groups ... 5.9 - Class level annotations ... invocationCount, The number of times this method...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@David91
Ok in that case, a class that has only 1
@Test
method should also reflect the same behaviour. If that’s not what is being seen then this for sure would be a defect.Yes, that’s correct. But it doesn’t call out how many times would the transform be invoked, which is what I was alluding towards 😃
Hi @krmahadevan
@Test
annotationtransform()
method works as expected. It gets invoked once@Test
annotation on top of the class, so it should be invoked once for that class. Also here is the description of thetransform()
method from TestNG official doc and it clearly describes when the method should be invoked.