junit-team/junit5 · error · JUnitException

Invalid DiscoveryIssue.Severity '%s' set via the '%s' config

Error message

Invalid DiscoveryIssue.Severity '%s' set via the '%s' configuration parameter.

What it means

Thrown by DiscoveryIssueCollector when the configuration parameter referenced by LauncherConstants.CRITICAL_DISCOVERY_ISSUE_SEVERITY_PROPERTY_NAME cannot be parsed into a DiscoveryIssue.Severity enum value. The value is uppercased and passed to Severity.valueOf(); any non-matching string raises a JUnitException wrapping the parse failure. Default severity when unset is Severity.ERROR.

Source

Thrown at junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/DiscoveryIssueCollector.java:58

	public void issueEncountered(UniqueId engineId, DiscoveryIssue issue) {
		this.issues.add(issue);
	}

	DiscoveryIssueNotifier toNotifier() {
		if (this.issues.isEmpty()) {
			return DiscoveryIssueNotifier.NO_ISSUES;
		}
		return DiscoveryIssueNotifier.from(criticalSeverity, this.issues);
	}

	private static Severity getCriticalSeverity(ConfigurationParameters configurationParameters) {
		return configurationParameters //
				.get(LauncherConstants.CRITICAL_DISCOVERY_ISSUE_SEVERITY_PROPERTY_NAME, value -> {
					try {
						return Severity.valueOf(value.toUpperCase(Locale.ROOT));
					}
					catch (Exception e) {
						throw new JUnitException(
							"Invalid DiscoveryIssue.Severity '%s' set via the '%s' configuration parameter.".formatted(
								value, LauncherConstants.CRITICAL_DISCOVERY_ISSUE_SEVERITY_PROPERTY_NAME));
					}
				}) //
				.orElse(Severity.ERROR);
	}
}

View on GitHub (pinned to 956246301e)

Solutions

  1. Check DiscoveryIssue.Severity enum constants in your JUnit version and use an exact match (case-insensitive).
  2. Remove the configuration parameter to fall back to the default (ERROR).
  3. Validate the value against Severity values before deploying junit-platform.properties.

Example fix

# before (junit-platform.properties)
junit.platform.launcher.discoveryIssue.critical.severity = fatal

# after
junit.platform.launcher.discoveryIssue.critical.severity = ERROR
Defensive patterns

Strategy: validation

Validate before calling

import org.junit.platform.engine.DiscoveryIssue.Severity;
String value = props.getProperty(LauncherConstants.CRITICAL_DISCOVERY_ISSUE_SEVERITY_PROPERTY_NAME);
if (value != null) {
    Severity.valueOf(value.toUpperCase(Locale.ROOT)); // throws early if invalid
}

Type guard

static boolean isValidSeverity(String v) {
    try { Severity.valueOf(v.toUpperCase(Locale.ROOT)); return true; }
    catch (Exception e) { return false; }
}

Prevention

When it happens

Trigger: Setting junit.platform.launcher.discoveryIssue.critical.severity (or the equivalent constant) to a value that is not one of the DiscoveryIssue.Severity enum constants, e.g. 'fatal', 'critical', 'err'. Passed via configurationParameter(), junit-platform.properties, or system property.

Common situations: Typos in junit-platform.properties. Copying an outdated severity name from documentation. Guessing 'CRITICAL' when the enum only defines NOTICE/WARNING/ERROR. Migration between JUnit versions where severity names changed.

Related errors


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