junit-team/junit5 · error · ParameterException
${e.getMessage()}
Error message
${e.getMessage()} What it means
This is a wrapper exception thrown by the picocli-based console launcher's BaseCommand.call() when a subcommand's execute() method throws a PreconditionViolationException. It converts the violation into a picocli ParameterException so the CLI can render usage help and a proper exit code rather than dumping a raw stack trace. The message content comes from the original precondition violation (e.getMessage()).
Source
Thrown at junit-platform-console/src/main/java/org/junit/platform/console/command/BaseCommand.java:85
commandLine.getErr().flush();
cmd.usage(commandLine.getOut());
return ExitCode.ANY_ERROR;
}) //
.setCaseInsensitiveEnumValuesAllowed(true) //
.setAtFileCommentChar(null);
}
@Override
public final T call() {
PrintWriter out = getOut();
if (!disableBanner) {
displayBanner(out);
}
try {
return execute(out);
}
catch (PreconditionViolationException e) {
throw new ParameterException(commandSpec.commandLine(), e.getMessage(), e.getCause());
}
}
private PrintWriter getOut() {
return commandSpec.commandLine().getOut();
}
private void displayBanner(PrintWriter out) {
out.println();
CommandLine.Help.ColorScheme colorScheme = getColorScheme();
if (colorScheme.ansi().enabled()) {
out.print("💚 ");
}
out.println(colorScheme.string(
"@|italic Thanks for using JUnit!|@ Support its development at @|underline https://junit.org/sponsoring|@"));
out.println();
out.flush();
}View on GitHub (pinned to f070c699a0)
Solutions
- Read the full error message: it is the downstream precondition text (e.getMessage()), which identifies which argument/selector is at fault — fix that argument.
- Re-run with --help on the specific subcommand (e.g. 'junit execute --help' or 'junit discover --help') to confirm accepted options and value formats.
- If the underlying cause chain is unclear, temporarily remove --disable-banner is not relevant; instead enable picocli's stack trace by inspecting the printed usage, or run a tiny Launcher API call to reproduce the precondition outside the CLI.
- Ensure the junit-platform-console and junit-platform-launcher versions are aligned (see error 112) so preconditions are not misreported.
Example fix
// before java -jar junit-platform-console-standalone.jar execute --select 'bad spec' --config='' // after: provide a valid selector and config value java -jar junit-platform-console-standalone.jar execute --select-class com.example.MyTests --config 'junit.jupiter.testinstance.lifecycle.default=per_class'
Defensive patterns
Strategy: try-catch
Validate before calling
// Validate selector strings before invoking the launcher programmatically.
// For the CLI case, validate args at the script level:
if (args.length == 0 || (!args[0].equals("discover") && !args[0].equals("execute"))) {
System.err.println("First arg must be 'discover' or 'execute' (or use --help/--version).");
System.exit(2);
}
Try / catch
// When embedding the launcher, catch PreconditionViolationException before it is wrapped.
try {
LauncherFactory.create().execute(request);
} catch (org.junit.platform.commons.PreconditionViolationException e) {
// handle invalid request construction
throw new IllegalArgumentException("Bad launcher request: " + e.getMessage(), e);
} Prevention
- When scripting the console launcher, validate the subcommand and selector options before invoking the jar.
- Test new CLI invocations locally with --help before wiring them into CI.
- Keep junit-platform-console, -launcher, and -engine versions aligned to avoid precondition differences.
When it happens
Trigger: Running the JUnit Platform Console Launcher (junit-platform-console[-standalone]) with invalid arguments that pass picocli parsing but fail a programmatic precondition inside a subcommand's execute() — e.g. mutually-exclusive options, a selector that cannot be resolved, or an invalid configuration parameter value. Any PreconditionViolationException raised downstream during discover/execute lands here.
Common situations: Invoking the standalone jar with a malformed --select, --scan-classpath with no matching classpath entries, passing --config KEY=VALUE with an invalid value, or combining options the subcommand later rejects. Common when scripting the console launcher in CI or from build tools.
Related errors
- Missing required subcommand
- Duplicate key '%s' for values '%s' and '%s'.
- Unsupported argument count validation mode: %s
- Invalid classpath entry: ${path}
- Failed to close custom class loader
AI-assisted analysis of junit-team/junit5@f070c699a0 (2026-08-11).
Data as JSON: /api/errors/165eea15ff4f100d.
Report an issue: GitHub.