Detailed instructions for using TestNG annotations

annotation                     describe
@BeforeSuite z-annotated methods are run only once, before running all tests in this suite
@AfterSuite z-annotated methods will only be run once, after all tests in this suite have run.
@AfterClass The z-annotated method will be run only once after all test methods already run in the current class
@BeforeTest The z-annotated method will be run before any test method belonging to the inner class's <test> tag is run
@BeforeGroups A list of z groups that this configuration method will run before. This method is guaranteed to run the first test method belonging to any of these method groups, that method is called
@AfterGroups   A list of z groups that will be run after this configuration method. This method is guaranteed to run shortly after the best test method that belongs to any of these groups is called
@BeforeMethod   z-annotated methods will run before each test method
@AfertMethod z the annotated method will be run after each test method
@DataProvider

b marks a method, a test method that provides data.

The annotated method must return an Object[][], where each Object[] can be assigned in the parameter list of the test method,

The @Test method, which wants to receive data from this DataProvider, needs to use a dataProvider whose name is equal to the name of the annotation

@Factory z As a factory, the object that returns TestNG's test class will be used for marked methods, which must return Object[]
@Listenners    d defines a listener for the test class
@Parameters d describes how to pass parameters to @Test methods
@Test b mark a class or method as part of the test
   

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325765797&siteId=291194637