TestNG @AfterClass Annotation
@AfterClass: The @AfterClass annotated method will be executed after all the test methods of a current class have been invoked.
Let's understand the @AfterClass annotation through an example.
Step 1: Open the Eclipse.
Step 2: We create a simple java project.
We define @AfterClass annotated method in the above classes. We define after_class() method in Class1 which runs after all the test methods of Class1 have been executed, and we also define @BeforeClass annotated method, i.e, after_class() in Class2 as well which runs after all the test methods of Class2 have been executed.
Step 3: Now, we create testng.xml file to configure the above two classes.
Step 4: Run the testng.xml file. Right click on the testng.xml file, move the cursor down to Run As and then click on the 1 TestNG Suite.