@Test Annotation with group
Lets create java class
package testngexp;
import org.testng.annotations.Test;
@Test
publicclass classlevelexamples {
publicvoid TestLoginMethod(){
System.out.println("this is Login Method");
}
@Test(groups="A")
publicvoid TestLogoutMethod(){
System.out.println("this is Logout Method");
}
}
TestNG.xml
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEsuiteSYSTEM"http://testng.org/testng-1.0.dtd">
<suitename="Suite"verbose="1">
<testname="Test1">
<groups>
<run>
<excludename="A"/>
</run>
</groups>
<classes>
<classname="testngexp.classlevelexamples"/>
</classes>
</test><!-- Test -->
</suite><!-- Suite -->
Results
Here, it is executed TestLoginMethod only because we are exclude that group in testng.xml file.
Note: if you defined <Include> in TestNG.xml both the methods will be executed
Comments
Post a Comment