junit-team/junit5 · info · TestAbortedException

Assumption failed

Error message

Assumption failed

What it means

Thrown as a TestAbortedException (not a test failure) when an assumption does not hold, via Assumptions.throwAssumptionFailed. JUnit treats a violated assumption as 'this test does not apply here' and marks the test as aborted/skipped rather than failed. The message is prefixed with 'Assumption failed: ' when a non-blank message is supplied, otherwise it is the bare 'Assumption failed'.

Solutions

  1. Treat as expected: if the test was correctly skipped, no action is needed — an aborted test is green/ignored, not a failure.
  2. If the test should have run, fix the condition/predicate passed to assumeTrue/assumeFalse so it matches the actual environment.
  3. Provide a descriptive message to assumeTrue(...) so the reason for the abort is obvious in the report.
  4. If you called abort() by mistake, replace it with the correct assertion or remove the call.

Example fix

// before
Assumptions.assumeTrue(false);
// after
Assumptions.assumeTrue(System.getProperty("os.name").toLowerCase().contains("linux"),
    "Test only runs on Linux");
Defensive patterns

Strategy: try-catch

Try / catch

try {
    Assumptions.assumeTrue(condition, "reason");
} catch (TestAbortedException ignored) {
    // expected when assumption does not hold; test is skipped
}

Prevention

When it happens

Trigger: Calling Assumptions.assumeTrue(false, msg), assumeFalse(condition that holds), assumingThat with a false predicate, or Assumptions.abort(...). Any code path reaching throwAssumptionFailed produces this TestAbortedException carrying the 'Assumption failed' message.

Common situations: Guarding tests that only run on a specific OS/JDK (assumeTrue(isLinux())); skipping tests when an external dependency (database, network, license) is absent; abort() used intentionally in @BeforeAll to skip a whole class; a third-party library asserting environment preconditions.

Related errors


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

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