junit-team/junit5 · error · JUnitException
Invalid ' ' set via the ' ' configuration parameter.
Error message
Invalid %s '%s' set via the '%s' configuration parameter.
What it means
JUnitException from EnumConfigurationParameterConverter.convert, thrown when a configuration parameter that should map to an enum constant cannot be parsed. The converter upper-cases and strips the supplied value, then calls Enum.valueOf; if that throws (no such constant), the whole thing is wrapped as a JUnitException naming the enum display name, the offending value, and the config key.
Solutions
- Check the enum's actual constant names in the JUnit version you target and use the exact name (case-insensitive after normalization).
- Strip surrounding quotes/whitespace from the value in junit.properties / -D argument.
- If migrating versions, look up the changelog for renamed/removed constants and update accordingly.
- The exception message echoes the normalized value it tried — use it to spot typos.
Example fix
// before (junit.properties) junit.jupiter.testclass.order.default = classname // after junit.jupiter.testclass.order.default = ClassName
Defensive patterns
Strategy: validation
Validate before calling
String raw = configParams.get(key).orElse(null);
if (raw != null) {
String norm = raw.strip().toUpperCase(Locale.ROOT);
Set<String> valid = Arrays.stream(enumType.getEnumConstants())
.map(Enum::name).collect(toSet());
if (!valid.contains(norm)) { /* invalid config value */ }
} Type guard
static <E extends Enum<E>> boolean isValidEnumValue(Class<E> enumType, String raw) {
try {
Enum.valueOf(enumType, raw.strip().toUpperCase(Locale.ROOT));
return true;
} catch (IllegalArgumentException e) {
return false;
}
} Try / catch
try {
Optional<E> v = converter.get(configParams, key);
} catch (JUnitException e) {
// message names the bad value and key; correct junit.properties / -D flag
} Prevention
- Use exact enum constant names (case-insensitive) in junit.properties / -D flags.
- Strip quotes/whitespace around config values.
- Re-check constant names when upgrading JUnit versions.
When it happens
Trigger: Setting a JUnit configuration parameter (e.g. junit.jupiter.execution.parallel.enabled, junit.jupiter.testclass.order.default, junit.jupiter.displayname.generator.default) to a value that is not a valid constant of the expected enum (e.g. typo, wrong case even after normalization, or a constant removed in a newer version).
Common situations: Typos in junit.properties or -D flags; copying a value from an older JUnit version whose enum constant was renamed/removed; locale-specific casing surprises (mitigated by Locale.ROOT upper-casing); trailing whitespace or quotes around the value.
Related errors
- AnnotationBasedArgumentsProvider does not override the…
- ArgumentsProvider does not override the…
- Implement generateDisplayNameForMethod(List<Class<?>>…
- Implement generateDisplayNameForNestedClass(List<Class<?>>…
- Implement scanForResourcesInClasspathRoot(URI…
AI-assisted analysis of junit-team/junit5@f070c699a0 (2026-08-11).
Data as JSON: /api/errors/13ed00353d406d33.
Report an issue: GitHub.
Appendix: source
Thrown at junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/config/EnumConfigurationParameterConverter.java:61
return configParams.get(key) //
.map(value -> convert(key, value));
}
public Optional<E> get(ExtensionContext extensionContext, String key) {
return extensionContext.getConfigurationParameter(key, value -> convert(key, value));
}
private E convert(String key, String value) {
String constantName = null;
try {
constantName = value.strip().toUpperCase(Locale.ROOT);
E result = Enum.valueOf(enumType, constantName);
logger.config(() -> "Using %s '%s' set via the '%s' configuration parameter.".formatted(enumDisplayName,
result, key));
return result;
}
catch (Exception ex) {
throw new JUnitException("Invalid %s '%s' set via the '%s' configuration parameter.".formatted(
enumDisplayName, constantName, key));
}
}
}
View on GitHub (pinned to f070c699a0)