Annotating test class methods using TestNG
When we start building test classes, we need to think about how we want to structure files. We are using TestNG as the test framework technology, so we will need to use the annotations it provides to tag the methods in the class.
Other things to consider: how to instantiate the required page object classes, how to declare local variables, when to use private methods in the class, how to pass data to the test methods, and how to structure Java methods so they become setup, teardown, and test methods. Let's get started on the test class structure itself.
Note
The documentation for TestNG is located at http://testng.org/doc/documentation-main.html.
TestNG annotations
Here is a list of the standard TestNG annotations available for test methods:
@Test
@Parameters
@DataProvider
@Listeners
@Factory
@BeforeSuite
and@AfterSuite
@BeforeTest
and@AfterTest
@BeforeGroups
and@AfterGroups
@BeforeClass
and@AfterClass
@BeforeMethod
and@AfterMethod
@Test
Let's build the test...