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 ...

Get Selenium Testing Tools Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.