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

org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter

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!

I think you should put your entire pom.xml and your test class in your question. I'm trying to help but wonder if your issue is reproducible. – Igor Flakiewicz Jan 21, 2022 at 17:10

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.

changed the return type of input method as: public static Stream<Arguments> input() { List<TestInput> input = new ArrayList<TestInput>(); } and made the return as: return Stream.of(Arguments.of(input)); In the test methods added the arguments as: @ParameterizedTest @MethodSource("input") public void testGetBlockNoByTxId(List<TestInput> input){} NOT WORKING – Tanaya Mitra Jan 21, 2022 at 10:39 <artifactId>junit-jupiter-engine</artifactId> <version>5.7.2</version> <artifactId>junit-jupiter-params</artifactId> <version>5.7.2</version> @Order(1) @ParameterizedTest @MethodSource("input") public void testChannelServiceDiscovery2() throws Exception {} public static Collection input() throws Exception { List<TestInput> input = new ArrayList<TestInput>(); return input; } The same works in a different project, wondering what i am missing! – Tanaya Mitra Jan 21, 2022 at 15:49 I recommend throwing out all your junit dependencies and just using junit-jupiter like in my example. Also if you are using spring-boot-starter-test that may contain some clashing dependencies that you may have to exclude. See stackoverflow.com/questions/48448331/… – Igor Flakiewicz Jan 21, 2022 at 15:57

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.