TestNG is an automation testing framework where NG is Next
Generation.
By using TestNG one can easily generate a report in HTML
format, and can analyse the number of test cases that have passed , failed and
skipped. It basically gives a overview of the test.
TestNG , like JUnit uses the annotations. i.e @ symbol
Why to use TestNG
with Selenium?
1. Selenium tests do produce results, but they are
not in a expected format for the test results. But by using TestNG one can
generate these much expected test results.
·
2. Generating the report in a proper format
includes number of test cases runs, the
number of test cases passed, the number of test cases failed, and the number of
test cases skipped.
·
3. Multiple test cases can be grouped easily by
converting them into.xml file. One can also prioritise which test case should
be executed first, middle or last.
·
4. The same test case can be executed multiple
times without loops just by using keyword called 'invocation count.'
·
Using
TestNG one can achieve cross browser testing.
·
The testing framework can be easily integrated
with build tools like Maven, Ant etc.
TestNG Annotations
@BeforeSuite: The annotated method will be run before
all tests in this suite have run.
@AfterSuite: The annotated method will be run after
all tests in this suite have run.
@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.
@BeforeTest: The annotated method will be run before
any test method belonging to the classes inside the tag is run.
@AfterTest: The annotated method will be run after
all the test methods belonging to the classes inside the tag have run.
@BeforeMethod: The annotated method will be run
before each test method.
@AfterMethod: The annotated method will be run after
each test method.
@Test: The annotated method is a part of a test case
@BeforeClass:
The annotated method will be run before the first test method in the current
class is invoked.
@AfterClass: The annotated method will be run after
all the test methods in the current class have been run.
No comments:
Post a Comment