TestNG

Table of contents
Reading Time: 2 minutes

‘TestNG is a testing framework which is inspired by junit. It 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-It gives the feature of test annotation.by using annotation we can easily understand.

3-It gives the feature to generate the report in HTML format and also XML format.

TestNG framework we can divide the testcases in three part.

1-@Beforemethod

2-@Test

3-@Aftermethod

@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 Test NG easily. TestNG’s plugin easily available for ECLIPSE IDE.

Here is the code of Test NG-

Test NG also generate the report in HTML format which are describe the your test case result which emailable-report.html.

TestNG

TestNG

Handle Multiple Test cases in Test NG-

In the end of test we need to execute all the test cases. these test cases dependent to each other. Test NG gives the functionality to execute these test cases simultaneously.

We need to create a testing.xml file which handle multiple test cases.

Testing.xml-

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 tag where we define test name. we can give the any name of test suite and test case but tag name is combination of package name and test name

Written by 

Principal Architect at Knoldus Inc

1 thought on “TestNG2 min read

Comments are closed.