There are many Before and After annotations in TestNG Framework. They are used to execute code before and after the execution of @Test annotated methods, Group of test methods, Test classes, etc.
Before and After Annotations
The following are the different Before and After annotations:
This method will be executed before and after any tests declared in the TestNG <suite> tag in the testng.xml file.
This method will be executed before and after the tests in the <test> tag in the TestNG testng.xml file.
@BeforeGroups annotated method will run before any of the test methods specified with the groups attribute. @AfterGroups annotated method will run after all the test methods specified with the groups attribute have run.
The @BeforeClass annotated test method is executed before any of the test methods in the test class. @AfterClass annotated method is executed after the execution of all the test methods in a test class.
These annotated methods are executed before and after the execution of each @Test annotated method.
To know the Annotations Execution Sequence Order,detailed example can be found here:
TestNG Tutorials on this website can be found at:
For more details on the TestNG Framework, visit the official website of TestNG at: