Jason Jason - 4 months ago 22
Java Question

Is there anyway to find all tests that are disabled in a TestNG suite?

In TestNG, you disable tests by doing the following in the method:

@Test(enabled = false)

I was wondering if there was an automated way to scrub the entire suite in order to find all of the methods that have enabled set to false?


You can use an IAnnotationTransformer:

public class MyTransformer implements IAnnotationTransformer {

  public void transform(ITest annotation, Class testClass, Constructor testConstructor, Method testMethod) {
    if (!annotation.getEnabled()) {
      System.out.println(testClass != null ? testClass : testMethod);