Created
June 15, 2023 20:00
-
-
Save eliasnogueira/c760551493c3aae589c3e4c906532d97 to your computer and use it in GitHub Desktop.
Simple example that explain how the MethodSource annotation from JUnit 5 works
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyTestClass { | |
@DisplayName("Date must be from the current year") | |
@ParameterizedTest(name = "Check the current year of {0}") | |
@MethodSource("dateList") | |
void myTest(LocalDate date) { | |
assertThat(date).hasYear(2023); | |
} | |
static Stream<Arguments> dateList() { | |
return Stream.of( | |
Arguments.arguments(LocalDate.parse("2023-08-15")), | |
Arguments.arguments(LocalDate.parse("2023-03-01")), | |
Arguments.arguments(LocalDate.parse("2023-10-23")) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment