junit-team/junit5 · error · PreconditionViolationException

${messageSupplier.get()}

Error message

${messageSupplier.get()}

What it means

Lazy-message variant of Preconditions.condition: throws PreconditionViolationException with messageSupplier.get() when the predicate is false. Identical semantics to the String variant (error 96) but the message is computed only on failure; used by hot paths to avoid building strings eagerly.

Source

Thrown at junit-platform-commons/src/main/java/org/junit/platform/commons/util/Preconditions.java:389

	public static void condition(boolean predicate, String message) throws PreconditionViolationException {
		if (!predicate) {
			throw new PreconditionViolationException(message);
		}
	}

	/**
	 * Assert that the supplied {@code predicate} is {@code true}.
	 *
	 * @param predicate the predicate to check
	 * @param messageSupplier precondition violation message supplier
	 * @throws PreconditionViolationException if the predicate is {@code false}
	 */
	@Contract("false, _ -> fail")
	public static void condition(boolean predicate, Supplier<String> messageSupplier)
			throws PreconditionViolationException {

		if (!predicate) {
			throw new PreconditionViolationException(messageSupplier.get());
		}
	}

}

View on GitHub (pinned to f070c699a0)

Solutions

  1. Read the message and locate the guard call site in the stack trace
  2. Fix the caller to meet the documented contract
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Any internal JUnit call to Preconditions.condition(predicate, () -> "msg") with predicate false - same as the eager variant but on the supplier overload.

Common situations: Same as error 96 - API misuse, contract violation, or bad inputs to a guarded method.

Related errors


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