Home | History | Annotate | Download | only in annotationtransformer
      1 package test.annotationtransformer;
      2 
      3 import org.testng.IAnnotationTransformer;
      4 import org.testng.annotations.ITestAnnotation;
      5 import org.testng.annotations.Test;
      6 
      7 import java.lang.reflect.Constructor;
      8 import java.lang.reflect.Method;
      9 
     10 public class AnnotationTransformerInvocationCountTest {
     11 
     12   public static class InvocationCountTransformer implements IAnnotationTransformer {
     13 
     14     private final int invocationCount;
     15 
     16     public InvocationCountTransformer(int invocationCount) {
     17       this.invocationCount = invocationCount;
     18     }
     19 
     20     @Override
     21     public void transform(ITestAnnotation annotation, Class testClass,
     22                           Constructor testConstructor, Method testMethod) {
     23       if ("concurrencyTest".equals(testMethod.getName())) {
     24         annotation.setInvocationCount(invocationCount);
     25       }
     26     }
     27   }
     28 
     29   @Test(invocationCount = 3)
     30   public void concurrencyTest() {
     31   }
     32 }
     33