TestNG Tutorial with Selenium

testng tutorial

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

It is an open source automated testing framework; where NG of TestNG means Next Generation. TestNG is similar to JUnit but it is much more powerful than JUnit but still it’s inspired by JUnit. It is designed to be better than JUnit, especially when testing integrated classes. Pay special thanks to Cedric Beust who is the creator of TestNG.

This eliminates most of the limitations of the older framework. It provides developer the ability to write more flexible and powerful tests with help of easy annotations, grouping, sequencing & parametrizing.

TestNG Tutorial Topics

Below is the list of topics which we are going to study in the next chapters of TestNg Tutorial:


What is TestNG, its Benefits and different Annotations available in it.


Installing TestNG Eclipse Plugin

It is easy to install TestNG, as it comes as a plugin for Eclipse IDE. Prerequisite for installing TestNG is your Internet connection should be up & running during installation of this plugin. And Eclipse IDE should be installed in your computer. 


Test Case

Hola, first test with using TestNg, get comfortable with it. How to run test with TestNG and a sneak look at the TestNG Reports.


Test Suite

In any project, you will end up to a place where you need to execute so many test cases on a run. Running a set of test cases together is call executing a Test Suite. Those test cases can be dependent to each other or may have to be executed in a certain order. TestNg gives us the capability to manage our test execution.


Annotations, Groups & OnDepends

Many annotations are available in TestNg which can be use to perform action before and after test, test suite etc. On top of that with @Test annotation, mulitple properties can be used such as Groups & DependsOnMethod for various reasons.


Prioritizing & Sequencing

Priority property is used with @Test annotation to prioritize the test. Like wise Enabled property is used to skip the test.


Reporters & Asserts

TestNG also gives us the logging facility for the test. For example during the running of test case user wants some information to be logged 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 which 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. Asserts are very important of any test, which are used to verify the conditions. TestNg provides many useful asserts with in it.


Parameters & Data Provider

Everybody knows the importance of Parameterization in testing and in automation testing. It allows us to automatically run a test case multiple times with different input and validation values. TestNG again gives us another interesting feature called TestNG Parameters. TestNG lets you pass parameters directly to your test methods with your testng.xml.


Data Provider with Excel

DataProvider helps to pass complex parameters to the test. These parameters can be Java (complex objects, objects read from a property file or a database, etc…). In such cases parameters can be passed using DataProviders.


Multi Browser, Cross Browser & Parallel Testing

In every project it is required to perform multi-browser testing. This make sure that the functionality is working as expected with every browser. Which allows to give equal user experience to all of the wide range of audience. It takes a considerable time to test everything on every browser. We have used automation to reduce the testing efforts, then why don’t we perform the multi-browser testing using automation. TestNG gives us functionality to perform same test on different browsers in a simple and easy way.



TestNG manages everything through Suite, Test and Methods and the Listeners gives us the ability to act before and after of every Suite, Test and Methods. There are many types of listeners available in TestNG for example IAnnotationTransformer, IAnnotationTransformer2, IConfigurable etc.

TestNG Tutorial, TestNG Tutorial, TestNG Tutorial, TestNG Tutorial, TestNG Tutorial, TestNG Tutorial, TestNG Tutorial