{"id":"82022a0bc3414bd0","repo":"junit-team/junit5","slug":"assumption-failed-82022a","errorCode":null,"errorMessage":"Assumption failed","messagePattern":"Assumption failed","errorType":"exception","errorClass":"TestAbortedException","httpStatus":null,"severity":"info","filePath":"junit-jupiter-api/src/main/java/org/junit/jupiter/api/Assumptions.java","lineNumber":339,"sourceCode":"\t *\n\t * <p>See Javadoc for {@link #abort(String)} for an explanation of this\n\t * method's generic return type {@code V}.\n\t *\n\t * @param messageSupplier the supplier of the message to be included in the\n\t * {@code TestAbortedException}\n\t * @throws TestAbortedException always\n\t * @since 5.9\n\t */\n\t@Contract(\"_ -> fail\")\n\t@API(status = STABLE, since = \"5.9\")\n\t@SuppressWarnings(\"TypeParameterUnusedInFormals\")\n\tpublic static <V> V abort(Supplier<String> messageSupplier) {\n\t\tthrow new TestAbortedException(messageSupplier.get());\n\t}\n\n\t@Contract(\"_ -> fail\")\n\tprivate static void throwAssumptionFailed(@Nullable String message) {\n\t\tthrow new TestAbortedException(\n\t\t\tStringUtils.isNotBlank(message) ? \"Assumption failed: \" + message : \"Assumption failed\");\n\t}\n\n}\n","sourceCodeStart":321,"sourceCodeEnd":344,"githubUrl":"https://github.com/junit-team/junit5/blob/956246301e03d757539f7b76dd5a91f298637563/junit-jupiter-api/src/main/java/org/junit/jupiter/api/Assumptions.java#L321-L344","documentation":"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.","triggerScenarios":"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.","commonSituations":"Tests that call the single-arg assumeTrue/assumeFalse overloads or pass a Supplier that returns null/empty, and the predicate evaluates false.","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."],"exampleFix":"// before\nassumeTrue(filesystem.isWritable());\n\n// after — add a message for diagnostics\nassumeTrue(filesystem.isWritable(), () -> \"filesystem not writable on \" + System.getProperty(\"os.name\"));","handlingStrategy":"validation","validationCode":"boolean ok = /* your condition */ true;\nif (!ok) {\n    // provide a non-blank message so the abort is diagnosable\n    org.junit.jupiter.api.Assumptions.assumeTrue(false, \"explain why this test is skipped\");\n}","typeGuard":null,"tryCatchPattern":"// Do not catch in tests. In custom runners:\ntry { executable.execute(); }\ncatch (org.opentest4j.TestAbortedException e) { /* record skip */ }","preventionTips":["Always pass a message to assumeTrue/assumeFalse/assumeNotNull to improve diagnostics.","Use declarative @Enabled* annotations for env-based gating."],"tags":["assumption","conditional-test-execution","test-aborted","junit-jupiter"],"analyzedSha":"956246301e03d757539f7b76dd5a91f298637563","analyzedAt":"2026-08-04T19:25:17.049Z","schemaVersion":2}