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
The following are the steps we need to begin with:
- Add TestNG dependency to the Maven
pom.xml
file:<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.4</version>
<scope>test</scope>
</dependency>
- Identify the set of values that we need ...
Get Selenium Testing Tools Cookbook - Second Edition 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.