C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
TestNG @AfterGroups AnnotationWe have learned about the @BeforeGroups annotation which executes the @BeforeGroups annotated method before the execution of the test methods belonging to the group specified in the parameter of the @BeforeGroups annotation. @AfterGroups: The @AfterGroups annotated method will run only once after the execution of all the test methods of a specified group. Let's understand the @AfterGroups annotation through an example: Step 1: Open the Eclipse. Step 2: We create a simple project. After_groups.java package com.TheDeveloperBlog; import org.testng.annotations.AfterGroups; import org.testng.annotations.Test; public class After_groups { @AfterGroups("Testing tool") public void after_group() { System.out.println("The list which is shown above are the testing tools"); } @Test(groups= {"Testing tool"}) public void testcase1() { System.out.println("Appium"); } @Test(groups= {"Testing tool"}) public void testcase2() { System.out.println("JIRA"); } @Test(groups= {"Testing tool"}) public void testcase3() { System.out.println("RedMine"); } } In the above java project, we have created the @AfterGroups annotated method and we pass the "TestingTool" which means that the @AfterGroups annotated method, i.e., after_group() will be invoked after execution of all the test methods belonging to the "Testing tool" group. Step 3: Now, we create a testng.xml file to configure the above class. Step 4: Run the testng.xml file. Right click on the testng.xml file and then move the cursor down to Run As and then click on the 1 TestNG Suite.
Next TopicTestNG Annotations
|