Can anyone explain the annotations available in TestNG?

0 votes
Jun 10 in Selenium by Ishika
21 views

1 answer to this question.

0 votes

Hi Ishika, following annotations are available in TestNG:

  1. @BeforeGroups: This method is guaranteed to run shortly before the first test method that belongs to any of these groups is invoked.

  2. @AfterGroups: This method is guaranteed to run shortly after the last test method that belongs to any of these groups is invoked.

  3. @BeforeMethod: The annotated method will be run before each test method.

  4. @AfterMethod: The annotated method will be run after each test method.

  5. @BeforeSuite: Run only once before all tests in this suite have run.

  6. @AfterSuite: Run only once after all tests in this suite have run.

  7. @BeforeClass: Run only once before the first test method in the current class is invoked.

  8. @AfterClass: Run only once after all the test methods in the current class have run.

  9. @BeforeTest: Run before any test method belonging to the classes inside the <test> tag is run.

  10. @AfterTest: Run after all the test methods belonging to the classes inside the <test> tag have run.

  11. @Listeners: Defines listeners on a test class.

  12. @Parameters: Describes how to pass parameters to a @Test method.

  13. @Test: Marks a class or a method as a part of the test.

  14. @DataProvider: Marks a method as supplying data for a test method. The annotated method must return an Object[ ][ ], where each Object[ ] can be assigned the parameter list of the test method. The @Test method that wants to receive data from this DataProvider needs to use a dataProvider name equals to the name of this annotation.

  15. @Factory: Marks a method as a factory that returns objects that will be used by TestNG as Test classes. The method must return Object[ ].

answered Jun 10 by Abha
• 20,110 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,070 points
435 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
786 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
430 views