Testng Tutorial: Install Testng Into Eclipse
Testng Tutorial: Install Testng Into Eclipse
What is TestNG ?
@BeforeGroups
The list of groups that this configuration method will run before. This method is
guaranteed to run shortly before the first test method that belongs to any of these
groups is invoked.
@AfterGroups
The list of groups that this configuration method will run after. This method is
guaranteed to run shortly after the last test method that belongs to any of these groups
is invoked.
@Factory
Marks a method as a factory that returns objects that will be used by TestNG as Test
classes. The method must return Object[ ].
@Listeners
Defines listeners on a test class.
@Parameters
Describes how to pass parameters to a @Test method.
@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.
Benefits of Using
Annotations
TestNG identifies the methods it is interested in, by looking up annotations.
Hence, method names are not restricted to any pattern or format.
We can pass additional parameters to annotations.
Annotations are strongly typed, so the compiler will flag any mistakes right
away.
Test classes no longer need to extend anything (such as TestCase, for JUnit 3).