Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IAnnotationTransformer doesn't run when specified as an @Listeners #446

Closed
rkonkul opened this issue Sep 17, 2013 · 7 comments
Closed

IAnnotationTransformer doesn't run when specified as an @Listeners #446

rkonkul opened this issue Sep 17, 2013 · 7 comments

Comments

@rkonkul
Copy link

rkonkul commented Sep 17, 2013

IAnnotationTransformer only works when specified in the suite xml file with . I would like it to also run the transformer when specified in the @Listener annotation

Example:

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import org.testng.IAnnotationTransformer;
import org.testng.annotations.ITestAnnotation;

public class TransformerImpl implements IAnnotationTransformer {

    @Override
    public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod) {
        System.out.println("Transform Annotation");
    }
}
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;

@Listeners({ TransformerImpl.class })
public class AnnotationTest {

    @Test
    public void run() {
        System.out.println("run");
    }
}
@rkonkul rkonkul closed this as completed Sep 17, 2013
@rkonkul rkonkul reopened this Sep 17, 2013
@rkonkul rkonkul closed this as completed Sep 23, 2013
@Aleks-Ya
Copy link

Aleks-Ya commented Apr 9, 2015

Why this issue was closed? The problem is alive (v. 6.8.21).

@rkonkul
Copy link
Author

rkonkul commented Apr 9, 2015

From the documentation: (http://testng.org/doc/documentation-main.html)

The @Listeners annotation can contain any class that extends org.testng.ITestNGListener except IAnnotationTransformer and IAnnotationTransformer2. The reason is that these listeners need to be known very early in the process so that TestNG can use them to rewrite your annotations, therefore you need to specify these listeners in your testng.xml file. 

@vinaybalepur
Copy link

Looks like the issue is still alive

@krmahadevan
Copy link
Member

krmahadevan commented Jun 11, 2018 via email

@Priya1405
Copy link

Hello,
So we would be able to add the IAnnotation Transformer as listener only in the testng.xml file not in the @Listener annotation is it?

@ChenaLee
Copy link

Changes note says @listeners is supported for IAnnotationTransformer since 6.9.10 version. However it still didn't work for me using 6.9.10.

@krmahadevan
Copy link
Member

@ChenaLee - Not true to the best of my knowledge. I think the javadocs makes this explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants