What are the annotations in TestNG?


The various annotations available in TestNG are listed below −

  • @Test – This is used before every test method in the java class file.

  • @BeforeSuite – This is used to run a particular test method before all the test methods.

  • @AfterSuite – This is used to run a particular test method after all the test methods.

  • @BeforeClass – This is used to run a particular test method only once before the first test method.

  • @AfterClass – This is used to run a particular test method only once after all the test methods in the present java class file are done with execution.

  • @BeforeTest – This is used to run before any test method inside the @Test tag.

  • @AfterTest – This is used to run after any test method inside the @Test tag.

  • @BeforeGroup – This is used to run a test method only once before every test method that belongs to a particular group.

  • @AfterGroup – This is used to run a test method only once after every test method that belongs to a particular group.

  • @BeforeMethod – This is used to run a test method before every test method present in that java class file.

  • @AfterMethod – This is used to run a test method after every test method present in that java class file.

Updated on: 19-Nov-2021

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements