Spring Boot - How to use JUnit Parameterized tests
JUnit Parameterized tests can be used within Spring Boot, there are only a couple of things that changes when you use @RunWith(Parameterized.class) instead of @RunWith(SpringRunner.class)
1. Enable JUnit Parameterized feature
Annotate the test class with: @RunWith(Parameterized.class)
2. Enable Spring Boot Testing
Annotate the test class with:
Add the following attributes to the test class:
3. Define the test cases data
JUnit uses a 2d Array to store the test cases data.
Add the following attribute to the test class:
For each test case a instance of the current class will be instantiated.
4. Write the actual tests
Now that all the data has been set, you can create the @Test methods that will be called for each test case.