junit-team/junit5 · info · TestAbortedException
Assumption failed
Error message
Assumption failed
What it means
Identical to errorIndex 1 (same throw site at Assumptions.java:339) but raised when the assumption fails with a blank/null message — StringUtils.isNotBlank(message) returns false, so the bare 'Assumption failed' text is used. It is a TestAbortedException signaling intentional test abort, not a failure.
Source
Thrown at junit-jupiter-api/src/main/java/org/junit/jupiter/api/Assumptions.java:339
*
* <p>See Javadoc for {@link #abort(String)} for an explanation of this
* method's generic return type {@code V}.
*
* @param messageSupplier the supplier of the message to be included in the
* {@code TestAbortedException}
* @throws TestAbortedException always
* @since 5.9
*/
@Contract("_ -> fail")
@API(status = STABLE, since = "5.9")
@SuppressWarnings("TypeParameterUnusedInFormals")
public static <V> V abort(Supplier<String> messageSupplier) {
throw new TestAbortedException(messageSupplier.get());
}
@Contract("_ -> fail")
private static void throwAssumptionFailed(@Nullable String message) {
throw new TestAbortedException(
StringUtils.isNotBlank(message) ? "Assumption failed: " + message : "Assumption failed");
}
}
View on GitHub (pinned to 956246301e)
Solutions
- Provide a descriptive message to make the abort easier to diagnose (pass a String or Supplier<String> to assumeTrue/assumeFalse).
- Verify the precondition genuinely holds in the current environment.
- If the abort is correct behavior, no code change is needed — just expect skipped tests in reports.
Example fix
// before
assumeTrue(filesystem.isWritable());
// after — add a message for diagnostics
assumeTrue(filesystem.isWritable(), () -> "filesystem not writable on " + System.getProperty("os.name")); Defensive patterns
Strategy: validation
Validate before calling
boolean ok = /* your condition */ true;
if (!ok) {
// provide a non-blank message so the abort is diagnosable
org.junit.jupiter.api.Assumptions.assumeTrue(false, "explain why this test is skipped");
} Try / catch
// Do not catch in tests. In custom runners:
try { executable.execute(); }
catch (org.opentest4j.TestAbortedException e) { /* record skip */ } Prevention
- Always pass a message to assumeTrue/assumeFalse/assumeNotNull to improve diagnostics.
- Use declarative @Enabled* annotations for env-based gating.
When it happens
Trigger: Calling assumeTrue(false), assumeFalse(true), or the no-message / null-message overloads (e.g., assumeTrue(boolean) with default 'assumption is not true'... note: the default literal IS non-blank so it goes to errorIndex 1; this branch is for explicitly null/blank messageSupplier results). Also assumeNotNull(null) without a message.
Common situations: Tests that call the single-arg assumeTrue/assumeFalse overloads or pass a Supplier that returns null/empty, and the predicate evaluates false.
Related errors
- Assumption failed:
- This class must not be instantiated
- Implement generateDisplayNameForNestedClass(List<Class<?>>,
- Implement generateDisplayNameForMethod(List<Class<?>>, Class
- This class must not be instantiated
AI-assisted analysis of junit-team/junit5@956246301e (2026-08-04).
Data as JSON: /data/errors/82022a0bc3414bd0.json.
Report an issue: GitHub.