C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
TestNG @AfterSuite Annotation@AfterSuite: The @AfterSuite annotated method is executed after the execution of all the test methods in the Suite. The Suite is basically a testng.xml file so we can say that @AfterSuite annotated method is executed after the execution of an XML file. The @BeforeSuite annotation is used to set up or start the selenium drivers while the @AfterSuite annotation is used to stop the selenium web drivers. Let's consider a simple example. Step 1: Open the Eclipse. Step 2: We create two java projects, i.e., Module1.java and Module2.java. Module1.java package com.TheDeveloperBlog; import org.testng.annotations.Test; public class Module1 { @Test public void a_test() { System.out.println("Test1"); } @Test public void b_test() { System.out.println("Test2"); } } Module2.java package com.TheDeveloperBlog; import org.testng.annotations.AfterSuite; import org.testng.annotations.Test; public class Module2 { @AfterSuite public void after_suite() { System.out.println("Last method"); } @Test public void c_test() { System.out.println("Test3"); } } Step 3: We create testng.xml file to configure classes. testng.xml file Till now, we created two classes, i.e., Module1 and Module2, and then we configure these two classes in the testng.xml file. The @AfterSuite annotated method is defined in Module2 class. Step 4: Run the testng.xml file. Right click on the testng.xml file and then move down to Run As and click on 1 TestNG Suite. Output
Next TopicTestNG Annotations
|