java config_error ai_generated true

org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [java.lang.String arg0] in method testFactory

ID: java/junit-test-factory-no-parameters

Also available as: JSON · Markdown · 中文
80%Fix Rate
83%Confidence
0Evidence
2025-06-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
8+ active

Root Cause

@TestFactory method has parameters but no source, or parameters are not supported for dynamic tests.

generic

中文

@TestFactory 方法有参数但缺少来源,或动态测试不支持参数。

Workarounds

  1. 95% success Remove parameters from @TestFactory method
    @TestFactory
    Stream<DynamicTest> testFactory() {
        return Stream.of("a", "b").map(input ->
            DynamicTest.dynamicTest("Test " + input, () -> {
                assertNotNull(input);
            })
        );
    }
  2. 70% success Use @TestTemplate instead
    @TestTemplate
    @ExtendWith(MyExtension.class)
    void testTemplate(String input) {
        // implementation
    }

Dead Ends

Common approaches that don't work:

  1. Adding @ParameterizedTest instead of @TestFactory 50% fail

    Changes test type; may not produce dynamic tests.

  2. Removing parameters and using hardcoded values 40% fail

    Reduces test flexibility.