TestNG is a testing framework which is inspired by junit. TestNG is the latest framework of selenium. it gives to complete freedom to write the testcases in group or dependent to the other method. NG stand for ‘NEXT GENERATION’. testing of next generation.
TestNG gives the lot of advantage over the other testing framework.
1-we can run the parallel test cases using TestNG.
2-TestNG gives the feature of test annotation.by using annotation we can easily understand.
3-TestNG gives the feature to generate the report in HTML format and also XML format.
TestNG framework we can divide the testcases in three part.
@Beforemethod- In before method we launch the Firefox or chrome driver get the URL.
@Test- In test we execute the main login of our test case.its like a main method.
@Aftermethod- we can write the close or quit method.
We can install the TestNG easily. TestNG plugin easily available for ECLIPSE IDE.
Here is the code of TestNG-
TestNG also generate the report in HTML format which are describe the your test case result which emailable-report.html.
Handle Multiple Test cases in TestNG-
In the end of test we need to execute all the test cases. these test cases dependent to each other. TestNG gives the functionality to execute these test cases simultaneously.
We need to create a testing.xml file which handle multiple test cases.
its a very simple XML code first of all we make a <suite> tag where we can define the test suite name after that we write <test> tag where we define test name. we can give the any name of test suite and test case but <class> tag name is combination of package name and test name