junit-team/junit5 · error · JUnitException

Invalid DiscoveryIssue.Severity

Error message

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

What it means

DiscoveryIssueCollector.getCriticalSeverity parses the junit.platform.discovery.issue.severity.critical configuration parameter via Severity.valueOf(value.toUpperCase(ROOT)). Any value that is not a DiscoveryIssue.Severity enum constant (ERROR, WARNING, INFO, etc.) causes the inner parse to throw, which is rethrown as a JUnitException naming the bad value and the property.

Solutions

  1. Set the value to a valid DiscoveryIssue.Severity constant: ERROR, WARNING, INFO (case-insensitive).
  2. Remove the property to fall back to the default (Severity.ERROR).
  3. Validate the value against DiscoveryIssue.Severity values at startup if you compute it dynamically.

Example fix

// before (junit-platform.properties)
junit.platform.discovery.issue.severity.critical=critical
// after
junit.platform.discovery.issue.severity.critical=ERROR
Defensive patterns

Strategy: validation

Validate before calling

// Validate the property value against the enum before launching
String v = config.get("junit.platform.discovery.issue.severity.critical").orElse("ERROR");
try { DiscoveryIssue.Severity.valueOf(v.toUpperCase(Locale.ROOT)); }
catch (IllegalArgumentException e) { throw new IllegalArgumentException("bad severity: " + v); }

Type guard

static boolean isValidSeverity(String v) {
    if (v == null || v.isBlank()) return true; // default applies
    try { DiscoveryIssue.Severity.valueOf(v.toUpperCase(Locale.ROOT)); return true; }
    catch (IllegalArgumentException e) { return false; }
}

Try / catch

try {
    launcher.execute(request);
} catch (JUnitException e) {
    if (e.getMessage().contains("Invalid DiscoveryIssue.Severity")) {
        // remove or correct the property and retry
    }
}

Prevention

When it happens

Trigger: Setting junit.platform.discovery.issue.severity.critical to a non-enum string (e.g. 'critical', 'fatal', 'warn', empty, or a typo like 'eror') in junit-platform.properties, system properties, or launcher configuration parameters.

Common situations: Typos in the property value; copying a severity name from another framework (TestNG/JUnit 4) that does not exist in DiscoveryIssue.Severity; upgrading JUnit where the enum constants were renamed; leftover config from an old tutorial.

Related errors


AI-assisted analysis of junit-team/junit5@f070c699a0 (2026-08-11). Data as JSON: /api/errors/0edb9f12937c5d8b. Report an issue: GitHub.

Appendix: 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 f070c699a0)