junit-team/junit5 · error · JUnitException
Invalid LauncherPhase '%s' set via the '%s' configuration pa
Error message
Invalid LauncherPhase '%s' set via the '%s' configuration parameter.
What it means
Thrown by LauncherPhase.getDiscoveryIssueFailurePhase() when the configuration parameter DISCOVERY_ISSUE_FAILURE_PHASE_PROPERTY_NAME cannot be parsed into a LauncherPhase enum value. The value is uppercased and passed to LauncherPhase.valueOf(); valid constants are DISCOVERY and EXECUTION. Any other value raises a JUnitException.
Source
Thrown at junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/LauncherPhase.java:38
import org.junit.platform.commons.JUnitException;
import org.junit.platform.engine.ConfigurationParameters;
/**
* The phase the {@link org.junit.platform.launcher.Launcher} is in.
*
* @since 1.13
*/
enum LauncherPhase {
DISCOVERY, EXECUTION;
static Optional<LauncherPhase> getDiscoveryIssueFailurePhase(ConfigurationParameters configurationParameters) {
Function<String, @Nullable LauncherPhase> stringLauncherPhaseFunction = value -> {
try {
return LauncherPhase.valueOf(value.toUpperCase(Locale.ROOT));
}
catch (Exception e) {
throw new JUnitException(
"Invalid LauncherPhase '%s' set via the '%s' configuration parameter.".formatted(value,
DISCOVERY_ISSUE_FAILURE_PHASE_PROPERTY_NAME));
}
};
return configurationParameters.get(DISCOVERY_ISSUE_FAILURE_PHASE_PROPERTY_NAME, stringLauncherPhaseFunction);
}
@Override
public String toString() {
return name().toLowerCase(Locale.ENGLISH);
}
}
View on GitHub (pinned to 956246301e)
Solutions
- Use exactly 'discovery' or 'execution' (case-insensitive) for the property value.
- Remove the property to use the default behaviour.
- Cross-check LauncherPhase enum and DISCOVERY_ISSUE_FAILURE_PHASE_PROPERTY_NAME in your JUnit version.
Example fix
# before junit.platform.launcher.discoveryIssue.failurePhase = runtime # after junit.platform.launcher.discoveryIssue.failurePhase = discovery
Defensive patterns
Strategy: validation
Validate before calling
String value = props.getProperty(DISCOVERY_ISSUE_FAILURE_PHASE_PROPERTY_NAME);
if (value != null) {
LauncherPhase.valueOf(value.toUpperCase(Locale.ROOT)); // throws early
} Type guard
static boolean isValidPhase(String v) {
try { LauncherPhase.valueOf(v.toUpperCase(Locale.ROOT)); return true; }
catch (Exception e) { return false; }
} Prevention
- Only use 'discovery' or 'execution' for the failure-phase property.
- Remove the property to accept defaults when unsure.
- Validate junit-platform.properties values against the enum in CI.
When it happens
Trigger: Setting junit.platform.launcher.discoveryIssue.failurePhase (per the constant) to something other than 'discovery' or 'execution', e.g. 'both', 'runtime', 'test'. Configured via configurationParameter(), junit-platform.properties, or system property.
Common situations: Typos in junit-platform.properties. Guessing a phase name. Documentation drift between JUnit versions where the property name or allowed values changed.
Related errors
- Invalid DiscoveryIssue.Severity '%s' set via the '%s' config
- Cannot override the standard style 'NONE'
- Could not read color palette properties
- Could not open color palette properties file
- Failed to transform configuration parameter with key '%s' an
AI-assisted analysis of junit-team/junit5@956246301e (2026-08-04).
Data as JSON: /data/errors/8641ccfc5ae06263.json.
Report an issue: GitHub.