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

  1. Use exactly 'discovery' or 'execution' (case-insensitive) for the property value.
  2. Remove the property to use the default behaviour.
  3. 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

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


AI-assisted analysis of junit-team/junit5@956246301e (2026-08-04). Data as JSON: /data/errors/8641ccfc5ae06263.json. Report an issue: GitHub.