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