{"record":{"id":"82022a0bc3414bd0","repo":"junit-team/junit5","slug":"assumption-failed","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/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-jupiter-api/src/main/java/org/junit/jupiter/api/Assumptions.java#L321-L344","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Treat as expected: if the test was correctly skipped, no action is needed — an aborted test is green/ignored, not a failure.","If the test should have run, fix the condition/predicate passed to assumeTrue/assumeFalse so it matches the actual environment.","Provide a descriptive message to assumeTrue(...) so the reason for the abort is obvious in the report.","If you called abort() by mistake, replace it with the correct assertion or remove the call."],"exampleFix":"// before\nAssumptions.assumeTrue(false);\n// after\nAssumptions.assumeTrue(System.getProperty(\"os.name\").toLowerCase().contains(\"linux\"),\n    \"Test only runs on Linux\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    Assumptions.assumeTrue(condition, \"reason\");\n} catch (TestAbortedException ignored) {\n    // expected when assumption does not hold; test is skipped\n}","preventionTips":["Make assumptions explicit and message them so aborts are self-documenting.","Distinguish assumeTrue (whole test) from assumingThat (scoped block).","Remember an aborted test is not a failure — no fix needed unless it should have run."],"tags":["assumption","test-aborted","skip","testabortedexception","junit-jupiter"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}