26
Dec

Short notes to understand different TestNG annotations

Annotation | Syntax | Description
—————————————————————————————————————————————–
@BeforeSuite | public void | The method will be run only once, before all the tests in the suite are executed.
@BeforeGroups | public void | The method will be run once, before all the configured group tests are executed.
@BeforeClass | public void | The method will be run only once before the first test method in the class in called.
@BeforeTest | public void | The method will be run before any test method belonging to the classes inside the tag is run.
@BeforeMethod | public void | The method will be run before each test method (@Test).

@AfterSuite | public void | The method will be run only once, after all the tests in the suite are executed.
@AfterGroups | public void | The method will be run once, after all the configured group tests are executed.
@AfterClass | public void | The method will be run only once after the first test method in the class in called.
@AfterTest | public void | The method will be run after any test method belonging to the classes inside the tag is run.
@AfterMethod | public void | The method will be run after each test method (@Test).

@Test | public void | Used with class or method, used to annotate test class or method
@DataProvider | public void | Used to define Iterative test data for TestNG methods
—————————————————————————————————————————————–