TestNG Framework – Introduction to TestNG

Definition of TestNG as per official site –

TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use.

A famous programmer named as “Cedric Beust” developed TestNG. It is distribute under Apache Software License and is easily available to download.
TestNG requires JDK 7 or higher.

Features of TestNG

1)   Report Generation – Selenium does not support report generation. TestNG provides the ability to generate HTML Reports

2)   Support for Annotations – It has inbuilt annotations, like @Test, @BeforeTest, @AfterTest, and soon which makes code more clean. These annotations are strongly typed, so the compiler will flag mistakes right away if any detected in the code.

3)   Grouping of Test Cases – It enable user to group the test cases easily. “Groups” is one annotation of TestNG that can be use in the execution of multiple tests.

4)   Set Test Execution Priority –   It enable user to set execution priorities of the test cases. There is a parameter called “Priority” which is used to execute the methods in a particular order. It also allows user to run the test cases of a particular group.

Let us consider a scenario where we have created two groups such as ‘Smoke’ and ‘Regression’. If we want to execute the test cases in a ‘Regression’ group, then this can only be possible in the TestNG framework. If we want to skip the execution of a particular test case, there is a parameter called (enabled = true or false)

 5)   Support Data Driven Testing –  It provide support to Data Driven testing using @DataProviders

 6)   Powerful Execution Model TestNG does not extend any class. TestNG framework allows user to define the test cases where each test case is independent of other test cases.


 7)   Supports Parallel or Multi Threading Testing – It allow user to run same test cases on 2 different browsers at the same time. 


 8)   Supports Logging It also provides the logging facility for the test. For example during the execution of test case, user wants some information to be log in the console. Information could be any detail depends upon the purpose. Keeping this in mind that we are using Selenium for testing, we need the information that helps the user to understand the test steps or any failure during the test case execution. With the help of TestNG Logs, it is possible to enable logging during the Selenium test case execution.


 9)   Integration with other third party tools – It can be easily integrated with other tools or plugins like build tool Maven, Integrated Development Environment (Eclipse), Selenium, Cucumber and many other.

There are lot more features apart from mentioned above, but I feel these are the most commonly used features in TestNG. 

Advertisement