org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter
while migrating from junit4 to junit5, instead of
@Parameterized.Parameters
public static Collection input() {}
I have added before all the test methods
@ParameterizedTest
@MethodSource("input")
but I am getting the error as : org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter
Any help appreciated!
Example of correct implementation of parameterized test:
//example with 2 parameters
@ParameterizedTest
@MethodSource("input")
void myTest(String input, String expectedResult) {
//test code
}
// Make sure to use the correct return type Stream<Arguments>
static Stream<Arguments> input() {
return Stream.of(
Arguments.of("hello", "hello"),
Arguments.of("bye", "bye")
//etc
);
}
Also make sure you are using a compatible version of junit jupiter:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${some.version}</version>
<scope>test</scope>
</dependency>
Also you need junit-vintage-engine
dependency if you still have junit4 tests.