Let's say we have a parameterized test exampleTest in JUnit5:
public class ExampleTestClass {
@ParameterizedTest(name = "exampleTest[{0}]")
@MethodSource("StringParams#getStrings")
void exampleTest(String input) {
// ...
}
}
public class StringParams {
static Stream<String> getStrings() {
return Stream.of("a", "b", "c");
}
}
Is there any way to execute only one instantiation of exampleTest in JUnit5? In JUnit4+Maven+Surefire, the following would work:
mvn test -Dtest="ExampleTestClass#exampleTest[a]"
But it doesn't seem to work with JUnit5+Maven+Surefire. Is it because the test names that get into the test selecting process (which tests will be executed and which are going to be omitted) are different from the one specified in @ParameterizedTest(name = "exampleTest[{0}])?