dimanche 31 janvier 2016

Disable particular tests through Annotation Transformer : TestNG

I have a huge project with numerous test cases. Some test cases are suppose to work on only particular environments and some are not. So I'm trying to skip or disable tests which don't belong to that environment.

I'm using Annotation Transformers to override @Test 's behaviour.

Here is my Transformer code in

package com.raghu.listener

public class SkipTestsTransformer implements IAnnotationTransformer {
    public void transform(ITestAnnotation annotation, Class testClass,
            Constructor testConstructor, java.lang.reflect.Method testMethod){

//          I intend to do this later
//          if(someCondition){
//              // Do something.
//          }
                System.out.println("Inside Transform");
    }
}

As of now I'm just trying to print.

I have many packages and classes on which I have to impose this Transformer.

How and Where should I initiate this class?

Please suggest any better methods for doing the same.

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire