Parameterized Tests
Explore how to create JUnit 5 parameterized tests that run multiple times with different inputs. Learn to use annotations such as @ValueSource, @EnumSource, @MethodSource, and @CsvSource to provide test data from literals, enums, methods, and CSV values, enhancing test coverage and efficiency.
We'll cover the following...
JUnit 5 allows a test to run multiple times with different arguments. They are declared like the normal tests, but we use the @ParameterizedTest annotation instead of the @Test annotation. This is helpful to test our method with various input data.
To run a parameterized test, we declare at least one Source that provides an argument for each function call. This is then passed to the test method.
Setup
To enable parameterized tests, we add the junit-jupiter-params ...