Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
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.
–
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.