Creating a data-driven test using JUnit
JUnit is a popular testing framework used to create Selenium WebDriver tests in Java. We can create data-driven Selenium WebDriver tests using the JUnit 4 parameterization feature. This can be done by using the JUnit parameterized class runner.
In this recipe, we will create a simple JUnit test case to test our BMI calculator application. We will specify the test data within our JUnit test case class. We will use various JUnit annotations to create a data-driven test.
Getting ready
The following are the things we need to do:
Set up a new project and add JUnit4 to the project's build path. You can set up the project in an IDE of your choice.
Identify the set of values that need to be tested.
How to do it...
Let's create a data-driven test using JUnit by following these steps:
Create a new JUnit test class that uses a parameterized runner using
@RunWith(Parameterized.class):
package com.secookbook.examples.chapter07; import org.openqa.selenium.firefox.FirefoxDriver...