TestNG Annotation is a piece of code which is inserted inside a program or business logic used to control the flow of execution of test methods.
TestNG Annotation |
Description |
@BeforeSuite |
The @BeforeSuite annotated method will run before the execution of all the test methods in the suite. |
@AfterSuite |
The @AfterSuite annotated method will run after the execution of all the test methods in the suite. |
@BeforeTest |
The @BeforeTest annotated method will be executed before the execution of all the test methods of available classes belonging to that folder. |
@AfterTest |
The @AfterTest annotated method will be executed after the execution of all the test methods of available classes belonging to that folder. |
@BeforeClass |
The @BeforeClass annotated method will be executed before the first method of the current class is invoked. |
@AfterClass |
The @AfterClass annotated method will be invoked after the execution of all the test methods of the current class. |
@BeforeMethod |
The @BeforeMethod annotated method will be executed before each test method will run. |
@AfterMethod |
The @AfterMethod annotated method will run after the execution of each test method. |
@BeforeGroups |
The @BeforeGroups annotated method run only once for a group before the execution of all test cases belonging to that group. |
@AfterGroups |
The @AfterGroups annotated method run only once for a group after the execution of all test cases belonging to that group. |