What is TestNG?

In the previous post, we have learnt about the desiredcapabilities in selenium. In this post, we will introduce you with a very important concept of Selenium automation Testing , which is TestNG Framework.

What is TestNG?

Till now , we were creating the classes having the main method which is the entry point for any execution of test cases. What if we don’t have main method in the classes? Can we execute test cases without having the main method in the classes?

It can be possible by using TestNG. TestNG is nothing but a testing Framework inspired by Junit(Unit testing framework) and Nunit(open source unit testing framework for Microsoft .NET). NG stands for next Generation.

TestNG was developed by Cedric Beust to overcome the limitations of Junit, which is another popular testing Framework used in Selenium. But TestNG is more powerful and easier to use that’s why it has become more popular and used by many developers because it provides the flexibility and ability to write more powerful test case with the help of annotations, grouping , sequencing & parameterizing.

It provide flexibility to execute a class separately or a group of classes.

Advantage of TestNg over Junit:

  • Annotations are easier to understand (more annotations than Junit)
  • Parallel testing is possible.
  • Possible to run a test case or a group of test case
  • In JUnit 4, we have to declare “@BeforeClass” and “@AfterClass” method as static method. In TestNg , we don’t have this constraint.
  • 3 additional annotations for entry and exit set up of code available in TestNG.
  • In Junit, annotation are bit confusing to understand like “Before”, “After” and “Expected”. It creates confusion what to do before, after and what is expected? In TestNg , it is simplified as “BeforeMethod”,”AfterMethos” and “ExpectedException” etc.
  • In TestNG , we can create a dependency of tests on each other by using “dependsOnMethods”.

Features of TestNG:

  • It provides a HTML report of all test cases execution.
  • Data input can be provided easily.
  • Generate logs.
  • Running group of test cases.

TestNg in Selenium

List Of Topics in TestNg:

  • TestNG Installation
  • Annotations in TestNG
  • Grouping and prioritizing of Test Cases
  • Running Test Cases as a Test Suite
  • TestNg Reporter Logs and Assertion
  • Dataprovider in TestNG
  • TestNg Listener
  • Difference between TestNG and Junit


Ask Question
Have any question or suggestion for us?Please feel free to post in Q&A Forum
Avatar photo

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

You may also like...