TestNG Tutorials

DataProvider in TestNG

Marks a method as supplying data for a test method. The annotated method must return an Object[][] where each Object[] can be assigned the parameter list of the test method.

The @Test method that wants to receive data from this DataProvider needs to use a dataProvider name equals to the name of this annotation.

The name of this data provider. If it's not supplied, the name of this data provider will automatically be set to the name of the method.

How to Install TestNG step by step

We will follow the below steps to install TestNG in Eclipse IDE .

There are two ways in installing TestNG in Eclipse

First Way on installing Eclipse is using "Install new software" option.

Second way is using "Eclipse Market Place". - This option will be available in new versions of eclipse.

NOTE: If your using eclipse latest version, please use Eclipse Marketplace option which is very simple, explained at the bottom.

TestNG Introduction

TestNG is a unit test framework designed for testing needs (developers / Test Engineers). It is inspired from JUnit by adding new functionalities which made TestNG more powerful than other unit test frameworks.

We can use TestNG for the below reasons:
1. To Run test cases in the order which we provide
2. We can run classes without using Main method.
3. To generate reports
4. We can Parameterize Tests
5. Group tests and execute only specific group
6. Implement logging using TestNG Listeners