Parameterized tests
Parameterized tests are a special kinds of tests in which the data input is injected in the test in order to reuse the same test logic. This concept was already addressed in JUnit 4, as explained in Chapter 1, Retrospective On Software Quality And Java Testing. As we would expect, parameterized tests are also implemented in JUnit 5.
First of all, in order to implement a parameterized test in Jupiter, we need to add the junit-jupiter-params
to our project. When using Maven, that means adding the following dependency:
<dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-params</artifactId> <version>${junit.jupiter.version}</version> <scope>test</scope> </dependency>
Note
As usual, as a general rule, it is recommended to use the latest version of the artifacts. To find out that, we can check out the Maven central repository (http://search.maven.org/).
When using Gradle, the junit...