Skip to main content

JUnit

JUnit parameterized tests

@ParameterizedTest

@ValueSource(strings = {"", "  "}) // simple primitive values (or Class type)
@NullSource // can be combined with ValueSource
@EmptySource // can be combined with ValueSource
@NullAndEmptySource // can be combined with ValueSource

@EnumSource(
  value = Month.class,
  names = {"APRIL", "JUNE", "SEPTEMBER", "NOVEMBER", "FEBRUARY"},
  mode = EnumSource.Mode.EXCLUDE)

@CsvSource(value = {"test:test", "tEst:test", "Java:java"}, delimiter = ':')
@CsvSource({"2018/12/25,2018", "2019/02/11,2019"})
    void testName(@ConvertWith(CustomDateConverter.class) LocalDate date, int expected)

@CsvFileSource(resources = "/data.csv", numLinesToSkip = 1)

@MethodSource("provideStringsForIsBlank")
@ArgumentsSource(CustomIMadeThisClassArgumentsProvider.class)