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
80%Fix Rate
83%Confidence
0Evidence
2025-06-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 8+ | active | — | — | — |
Root Cause
@TestFactory method has parameters but no source, or parameters are not supported for dynamic tests.
generic中文
@TestFactory 方法有参数但缺少来源,或动态测试不支持参数。
Workarounds
-
95% success Remove parameters from @TestFactory method
@TestFactory Stream<DynamicTest> testFactory() { return Stream.of("a", "b").map(input -> DynamicTest.dynamicTest("Test " + input, () -> { assertNotNull(input); }) ); } -
70% success Use @TestTemplate instead
@TestTemplate @ExtendWith(MyExtension.class) void testTemplate(String input) { // implementation }
Dead Ends
Common approaches that don't work:
-
Adding @ParameterizedTest instead of @TestFactory
50% fail
Changes test type; may not produce dynamic tests.
-
Removing parameters and using hardcoded values
40% fail
Reduces test flexibility.