@BeforeSuite and @AfterSuite
@Before Suite :The annotated method will be run before all tests in this suite have run.
@After Suite :The annotated method will be run after all tests in this suite have run.
Java Class
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
importorg.testng.annotations.Test;
publicclass TestNGExample {
@BeforeSuite
publicvoid BeforeSuiteSample(){
System.out.println("This Method will Execute before suite");
}
@AfterSuite
publicvoid AfterSuiteSample(){
System.out.println("This Method will Execute After Suite");
}
}
TestNG.xml file
<?xmlversion="1.0"encoding="UTF-8"?>
<!DOCTYPEsuiteSYSTEM"http://testng.org/testng-1.0.dtd">
<suitename="Suite"parallel="none">
<testname="Test">
<classes>
<classname="TestNGExample"/>
</classes>
</test><!-- Test -->
</suite><!-- Suite -->
Note:@Before Suite and @After Suite will execute only once
Comments
Post a Comment