1 package test.annotationtransformer; 2 3 import org.testng.IAnnotationTransformer3; 4 import org.testng.annotations.IConfigurationAnnotation; 5 import org.testng.annotations.IDataProviderAnnotation; 6 import org.testng.annotations.IFactoryAnnotation; 7 import org.testng.annotations.IListenersAnnotation; 8 import org.testng.annotations.ITestAnnotation; 9 10 import java.lang.reflect.Constructor; 11 import java.lang.reflect.Method; 12 13 public class MyListenerTransformer implements IAnnotationTransformer3 { 14 15 @Override transform(IListenersAnnotation annotation, Class testClass)16 public void transform(IListenersAnnotation annotation, Class testClass) { 17 annotation.setValue(new Class[]{MySuiteListener2.class}); 18 } 19 20 @Override transform(IConfigurationAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod)21 public void transform(IConfigurationAnnotation annotation, Class testClass, 22 Constructor testConstructor, Method testMethod) {} 23 24 @Override transform(IDataProviderAnnotation annotation, Method method)25 public void transform(IDataProviderAnnotation annotation, Method method) {} 26 27 @Override transform(IFactoryAnnotation annotation, Method method)28 public void transform(IFactoryAnnotation annotation, Method method) {} 29 30 @Override transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, Method testMethod)31 public void transform(ITestAnnotation annotation, Class testClass, Constructor testConstructor, 32 Method testMethod) {} 33 } 34