junit-team/junit5 · error · PreconditionViolationException
Configuration error: %s.
Error message
Configuration error: %s.
What it means
Thrown by ResolverFacade.configurationErrorOrSuccess() when there is exactly one configuration error detected during validation of parameter/field declarations for a parameterized test or class. The method accumulates error messages in a List and, if exactly one error exists, formats it as 'Configuration error: <message>.' The error message comes from validation logic that checks parameter declarations, aggregator declarations, and field parameter declarations for issues like duplicate aggregators, invalid parameter indices, or type mismatches.
Source
Thrown at junit-jupiter-params/src/main/java/org/junit/jupiter/params/ResolverFacade.java:386
parameterName(actualDeclaration), parameterIndex));
}
else if (errors.isEmpty()) {
parameterDeclarationMapping.put(actualDeclaration, originalDeclaration);
}
}
return errors;
}
private static String parameterName(ParameterDeclaration actualDeclaration) {
return actualDeclaration.getParameterName().map(name -> " '" + name + "'").orElse("");
}
private static <T> T configurationErrorOrSuccess(List<String> errors, Supplier<T> successfulResult) {
if (errors.isEmpty()) {
return successfulResult.get();
}
else if (errors.size() == 1) {
throw new PreconditionViolationException("Configuration error: " + errors.get(0) + ".");
}
else {
throw new PreconditionViolationException("%d configuration errors:%n%s".formatted(errors.size(),
errors.stream().collect(joining(lineSeparator() + "- ", "- ", ""))));
}
}
private static void validateIndexedParameters(
NavigableMap<Integer, List<FieldParameterDeclaration>> indexedParameters, List<String> errors) {
if (indexedParameters.isEmpty()) {
return;
}
indexedParameters.forEach(
(index, declarations) -> validateIndexedParameterDeclarations(index, declarations, errors));
for (int index = 0; index <= indexedParameters.lastKey(); index++) {View on GitHub (pinned to f070c699a0)
Solutions
- Read the specific error message after 'Configuration error:' — it identifies the exact parameter/field and issue
- Check @Parameter indices, @ConvertWith/@AggregateWith annotations, and parameter types against the argument source
- Ensure there are no duplicate or conflicting parameter declarations
- For @ParameterizedClass, verify @Parameter field indices are contiguous starting from 0
Example fix
// before — invalid parameter annotation
@ParameterizedTest
@CsvSource({ "1,hello" })
void test(@ConvertWith(MyStringConverter.class) int number, String text) {
// MyStringConverter tries to convert to int → configuration error
}
// after — correct annotation or type
@ParameterizedTest
@CsvSource({ "1,hello" })
void test(int number, String text) { } Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate parameter annotations on a @ParameterizedTest method
import java.lang.reflect.Parameter;
import java.lang.reflect.Method;
static void validateParameterizedTestParams(Method testMethod) {
for (Parameter p : testMethod.getParameters()) {
boolean hasConvertWith = p.isAnnotationPresent(org.junit.jupiter.params.converter.ConvertWith.class);
boolean hasAggregateWith = p.isAnnotationPresent(org.junit.jupiter.params.AggregateWith.class);
// Check for known issues: conflicting annotations, invalid types, etc.
if (hasConvertWith && hasAggregateWith) {
throw new IllegalStateException(
"Parameter " + p.getName() + " cannot have both @ConvertWith and @AggregateWith");
}
}
} Prevention
- Review the full error message — it identifies the exact parameter and the nature of the configuration problem
- Validate parameter annotations match the argument source shape before running tests
- Ensure @Parameter indices are within the argument source's column range
When it happens
Trigger: Exactly one validation error is found when resolving parameters for a @ParameterizedTest method or @ParameterizedClass constructor/fields. For example: a single @AggregateWith annotation on a non-aggregatable parameter, a single @Parameter field with an invalid index, or one parameter type that can't be resolved by any registered resolver.
Common situations: Parameterized test methods where one parameter has an incompatible @ConvertWith or @AggregateWith annotation. @ParameterizedClass fields where one @Parameter field index is out of range. A single parameter declaration that conflicts with JUnit's resolution rules (e.g., two parameters mapping to the same index but only one is flagged at this pass).
Related errors
- %d configuration errors:%n%s
- Parameter resolution is disabled
- Constructor injection is not supported for @ParameterizedCla
- Configuration error: You must configure at least one set of
- The display name pattern defined for the parameterized test
AI-assisted analysis of junit-team/junit5@f070c699a0 (2026-08-11).
Data as JSON: /api/errors/dad8912e9e7a3d25.
Report an issue: GitHub.