diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/ExceptionHandlingTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/ExceptionHandlingTests.java index 7403023afcb1..a89405d11b44 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/ExceptionHandlingTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/ExceptionHandlingTests.java @@ -24,7 +24,7 @@ import static org.junit.platform.testkit.engine.EventConditions.test; import static org.junit.platform.testkit.engine.TestExecutionResultConditions.isA; import static org.junit.platform.testkit.engine.TestExecutionResultConditions.message; -import static org.junit.platform.testkit.engine.TestExecutionResultConditions.suppressed; +import static org.junit.platform.testkit.engine.TestExecutionResultConditions.suppressedThrowable; import java.io.IOException; import java.util.Optional; @@ -132,7 +132,7 @@ void checkedExceptionInAfterEachIsSuppressedByExceptionInTest() { finishedWithFailure(allOf( // isA(RuntimeException.class), // message("unchecked"), // - suppressed(0, allOf(isA(IOException.class), message("checked")))))), // + suppressedThrowable(0, allOf(isA(IOException.class), message("checked")))))), // event(container(testClass), finishedSuccessfully()), // event(engine(), finishedSuccessfully())); } @@ -151,7 +151,7 @@ void exceptionInAfterEachTakesPrecedenceOverFailedAssumptionInTest() { finishedWithFailure(allOf( // isA(IOException.class), // message("checked"), // - suppressed(0, allOf(isA(TestAbortedException.class)))))), // + suppressedThrowable(0, allOf(isA(TestAbortedException.class)))))), // event(container(FailureTestCase.class), finishedSuccessfully()), // event(engine(), finishedSuccessfully())); } @@ -197,7 +197,7 @@ void exceptionInAfterAllCallbackDoesNotHideExceptionInBeforeAllCallback() { event(container(testClass), started()), // event(container(testClass), finishedWithFailure(allOf( // message("beforeAll callback"), // - suppressed(0, message("afterAll callback"))))), // + suppressedThrowable(0, message("afterAll callback"))))), // event(engine(), finishedSuccessfully())); } @@ -237,7 +237,7 @@ void failureInAfterAllTakesPrecedenceOverTestAbortedExceptionInBeforeAll() { event(container(FailureTestCase.class), started()), // event(container(FailureTestCase.class), finishedWithFailure(allOf(isA(IOException.class), message("checked"), - suppressed(0, allOf(isA(TestAbortedException.class), message("aborted")))))), // + suppressedThrowable(0, allOf(isA(TestAbortedException.class), message("aborted")))))), // event(engine(), finishedSuccessfully())); } diff --git a/junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/extension/ProgrammaticExtensionRegistrationTests.java b/junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/extension/ProgrammaticExtensionRegistrationTests.java index 6a2ef3ba7bc9..9ff3488acdd9 100644 --- a/junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/extension/ProgrammaticExtensionRegistrationTests.java +++ b/junit-jupiter-engine/src/test/java/org/junit/jupiter/engine/extension/ProgrammaticExtensionRegistrationTests.java @@ -17,7 +17,7 @@ import static org.junit.platform.testkit.engine.EventConditions.finishedWithFailure; import static org.junit.platform.testkit.engine.TestExecutionResultConditions.isA; import static org.junit.platform.testkit.engine.TestExecutionResultConditions.message; -import static org.junit.platform.testkit.engine.TestExecutionResultConditions.nestedCause; +import static org.junit.platform.testkit.engine.TestExecutionResultConditions.nestedThrowable; import java.lang.reflect.Field; import java.util.function.Predicate; @@ -83,14 +83,15 @@ void classLevelFromInterface() { @Test void propagatesCheckedExceptionThrownDuringInitializationOfStaticField() { - assertClassFails(ClassLevelExplosiveCheckedExceptionTestCase.class, - allOf(isA(ExceptionInInitializerError.class), nestedCause(allOf(isA(Exception.class), message("boom"))))); + assertClassFails(ClassLevelExplosiveCheckedExceptionTestCase.class, allOf( + isA(ExceptionInInitializerError.class), nestedThrowable(allOf(isA(Exception.class), message("boom"))))); } @Test void propagatesUncheckedExceptionThrownDuringInitializationOfStaticField() { - assertClassFails(ClassLevelExplosiveUncheckedExceptionTestCase.class, allOf( - isA(ExceptionInInitializerError.class), nestedCause(allOf(isA(RuntimeException.class), message("boom"))))); + assertClassFails(ClassLevelExplosiveUncheckedExceptionTestCase.class, + allOf(isA(ExceptionInInitializerError.class), + nestedThrowable(allOf(isA(RuntimeException.class), message("boom"))))); } @Test diff --git a/junit-platform-testkit/src/main/java/org/junit/platform/testkit/engine/EventConditions.java b/junit-platform-testkit/src/main/java/org/junit/platform/testkit/engine/EventConditions.java index 207b6ff861d5..adbee81b6238 100644 --- a/junit-platform-testkit/src/main/java/org/junit/platform/testkit/engine/EventConditions.java +++ b/junit-platform-testkit/src/main/java/org/junit/platform/testkit/engine/EventConditions.java @@ -140,7 +140,7 @@ private static Condition finishedWithCause(Status expectedStatus, Condition causeCondition) { return finished(Assertions.allOf(TestExecutionResultConditions.status(expectedStatus), - TestExecutionResultConditions.cause(causeCondition))); + TestExecutionResultConditions.throwable(causeCondition))); } public static Condition finishedWithFailure() { diff --git a/junit-platform-testkit/src/main/java/org/junit/platform/testkit/engine/TestExecutionResultConditions.java b/junit-platform-testkit/src/main/java/org/junit/platform/testkit/engine/TestExecutionResultConditions.java index 846386f1e8f2..03fa896615d7 100644 --- a/junit-platform-testkit/src/main/java/org/junit/platform/testkit/engine/TestExecutionResultConditions.java +++ b/junit-platform-testkit/src/main/java/org/junit/platform/testkit/engine/TestExecutionResultConditions.java @@ -40,23 +40,23 @@ public static Condition status(Status expectedStatus) { expectedStatus); } - public static Condition cause(Condition condition) { + public static Condition throwable(Condition condition) { return new Condition<>( where(TestExecutionResult::getThrowable, throwable -> throwable.isPresent() && condition.matches(throwable.get())), - "cause matches %s", condition); + "throwable matches %s", condition); } - public static Condition nestedCause(Condition condition) { - return new Condition<>(throwable -> condition.matches(throwable.getCause()), "nested cause matches %s", + public static Condition nestedThrowable(Condition condition) { + return new Condition<>(throwable -> condition.matches(throwable.getCause()), "nested throwable matches %s", condition); } - public static Condition suppressed(int index, Condition condition) { + public static Condition suppressedThrowable(int index, Condition condition) { return new Condition<>( throwable -> throwable.getSuppressed().length > index && condition.matches(throwable.getSuppressed()[index]), - "suppressed exception at index %d matches %s", index, condition); + "suppressed throwable at index %d matches %s", index, condition); } public static Condition isA(Class expectedType) { @@ -69,7 +69,7 @@ public static Condition message(String expectedMessage) { } public static Condition message(Predicate expectedMessagePredicate) { - return new Condition<>(where(Throwable::getMessage, expectedMessagePredicate), "message predicate"); + return new Condition<>(where(Throwable::getMessage, expectedMessagePredicate), "message matches predicate"); } }