Ignore Test


Sometimes , user wants to ignore some test case (means he doesn’t want to run), in such cases you can use Enabled along with @Test annotation

Lets create java class

import org.testng.annotations.Test;
publicclassignorecase {
@Test//default enable=true
publicvoid test1() {
System.out.println("This test1 method");
}
@Test(enabled = true)
publicvoid test2() {
System.out.println("This test2 method");
}
@Test(enabled = false)
publicvoid test3() {
System.out.println("This test3 method");
}
}

TestNG.xml

<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEsuiteSYSTEM"http://testng.org/testng-1.0.dtd">
<suitename="Suite"parallel="none">
<testname="Test1">
<classes>
<classname="ignorecase"/>
</classes>
</test><!-- Test -->
</suite><!—Suite -->

Results
image
Here, it will run one test1 and test2 methods only because test3 is enabled =false

Comments