I would like to define a custom descriptor for the display name of a testcase in a Junit5 ParameterizedTest. Here is my current solution:
/**
* @param name
* is the testcase display name
*/
@ParameterizedTest(name = "{0}")
@MethodSource
void testNotNull(final String name, final String value) {
assertNotNull(sut.bar(value));
}
private static Stream<Arguments> testNotNull() {
return Stream.of(Arguments.of("empty string", ""),
Arguments.of("string with no alphanumerical prefix", "123"),
Arguments.of("null string", null));
}
The only thing I dislike about this solution is having to define a JavaDoc Parameter for name
in order to avoid warnings in my IDE.
Is there a better way to achieve this?