Jason Jason - 1 year ago 67
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?

Answer Source

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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download