How to disable the whole unit test in TestNG?

This is what I can do in JUnit:

import org.junit.*; @Ignore public class FooTest { // } 

and the whole class will be ignored. How can I do the same in TestNG?

+47
java unit-testing junit testng
Jun 02 2018-11-11T00:
source share
1 answer

I believe you want:

 @Test(enabled=false) public class FooTest { // } 

(You can apply the @Test annotation to the class, as well as to methods individually.)

The TestNG documentation contains an exhaustive list of supported annotations, and also describes the exclusion / inclusion of tests by group, if interested. Here is a quote from the relevant section:

@Test Marks a class or method as part of a test.

... (notch) ...

included: whether methods of this class / method are included.

EDIT : Ignoring a class using @Test(enabled=false) seems to be erroneous functionality in some versions of TestNG according to this defect , which was raised against TestNG.

+69
Jun 02 2018-11-11T00:
source share



All Articles