O'Reilly logo

Selenium Testing Tools Cookbook by Unmesh Gundecha

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

Creating a data-driven test using TestNG

TestNG is another widely used testing framework with Selenium WebDriver. It is very similar to JUnit. TestNG has rich features for testing, such as parameterization, parallel test execution, and so on.

TestNG provides the DataProvider feature to create data-driven tests. In this recipe, we will use the DataProvider feature to create a simple test. Creating data-driven tests in TestNG is fairly easy, when compared with JUnit.

Getting ready

  • Download and install TestNG from http://testng.org/doc/index.html.
  • Set up a new project and add TestNG to the project's build path. You can set up the project in an IDE of your choice.
  • Identify the set of values that we need to test.

How to do it...

Let's parameterize a TestNG ...

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