-
-
Couldn't load subscription status.
- Fork 1.6k
Description
Overview
In the following code snippet, the Weld CDI system provides a ParameterResolver for the third parameter in the parametersTakePriorityOverInjection() method. Since the@TestTemplate "knows" that it's producing parameters for the first two parameters via its ArgumentSource, it shouldn't call either the supportsParameter() or resolvesParameter() methods of Weld's ParameterResolver. Other registered ParameterResolvers should only be called for parameters with indexes greater than one.
@ExtendWith(WeldJunit5Extension.class)
public class ParameterizedTestCompatibilityTest {
static final String SENTENCE = " is a greek letter.";
@ParameterizedTest
@CsvSource({
"Alpha, 0",
"Beta, 1",
"Gamma, 2"
})
void parametersTakePriorityOverInjection(String letter, int ordinal, String sentence) {
assertTrue(letter.length() >= 4);
assertTrue(ordinal >= 0 && ordinal <= 2);
assertEquals(SENTENCE, sentence);
}
@Produces
@ApplicationScoped
String produceSentence() {
return " is a greek letter.";
}
}When run, this code currently throws a ParameterResolutionException with the message:
Discovered multiple competing ParameterResolvers for parameter [java.lang.String arg0] in executable [void org.jboss.weld.junit5.compatibility.ParameterizedTestCompatibilityTest.parametersTakePriorityOverInjection(java.lang.String,int,java.lang.String)]: org.jboss.weld.junit5.WeldJunit5Extension, org.junit.jupiter.params.ParameterizedTestParameterResolver
This issue is somewhat related to #935 but occurs when additional parameters are correctly placed after those injected by the TestTemplate.
Versions
junit-jupiter-api: 5.0.1, 5.0.2, 5.1 M1junit-jupiter-params: 5.0.1, 5.0.2, 5.1 M1
Related Issues
- ParameterResolutionException with TestInfo and Parameterized Tests #935
- Create a JUnit 5 Extension to create test instances for the engine weld/weld-testing#3
- Introduce an option to make Weld injection more restrictive weld/weld-testing#13
Deliverables
- Parameterized tests should ignore other registered parameter resolvers for parameters that will be satisfied by an
ArgumentSource.