O'Reilly logo

TestNg Beginner's Guide by Varun Menon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

DataProvider

One of the important features provided by TestNG is the DataProvider feature. It helps the user to write data-driven tests, that means same test method can be run multiple times with different datasets. DataProvider is the second way of passing parameters to test methods. It helps in providing complex parameters to the test methods as it is not possible to do this from XML.

To use the DataProvider feature in your tests you have to declare a method annotated by DataProvider and then use the said method in the test method using the dataProvider attribute in the Test annotation.

Lets write a simple example and learn how to use the DataProvider feature in our tests.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required