diff --git a/integration-tests/main/src/test/java/io/quarkus/it/main/QuarkusTestCallbacksTestCase.java b/integration-tests/main/src/test/java/io/quarkus/it/main/QuarkusTestCallbacksTestCase.java index c61618bdcc2b5..305b2136b90a3 100644 --- a/integration-tests/main/src/test/java/io/quarkus/it/main/QuarkusTestCallbacksTestCase.java +++ b/integration-tests/main/src/test/java/io/quarkus/it/main/QuarkusTestCallbacksTestCase.java @@ -114,6 +114,12 @@ public void testCallbackContextIsFailed() { assertTrue(TestContextCheckerBeforeEachCallback.CONTEXT.getTestStatus().isTestFailed()); } + @Test + @Order(6) + public void testCallbackContextIsNotFailedAgain() { + assertTrue(TestContextCheckerBeforeEachCallback.CONTEXT.getTestStatus().isTestFailed()); + } + @Target({ METHOD }) @Retention(RUNTIME) public @interface TestAnnotation { diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/AbstractQuarkusTestWithContextExtension.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/AbstractQuarkusTestWithContextExtension.java index 037e4946b58e2..68b1b601ed90c 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/AbstractQuarkusTestWithContextExtension.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/AbstractQuarkusTestWithContextExtension.java @@ -4,13 +4,21 @@ import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.LifecycleMethodExecutionExceptionHandler; +import org.junit.jupiter.api.extension.TestExecutionExceptionHandler; import org.junit.jupiter.api.extension.TestWatcher; public abstract class AbstractQuarkusTestWithContextExtension extends AbstractTestWithCallbacksExtension - implements LifecycleMethodExecutionExceptionHandler, TestWatcher { + implements TestExecutionExceptionHandler, LifecycleMethodExecutionExceptionHandler, TestWatcher { public static final String IO_QUARKUS_TESTING_TYPE = "io.quarkus.testing.type"; + @Override + public void handleTestExecutionException(ExtensionContext context, Throwable throwable) throws Throwable { + markTestAsFailed(context, throwable); + + throw throwable; + } + @Override public void handleAfterAllMethodExecutionException(ExtensionContext context, Throwable throwable) throws Throwable { markTestAsFailed(context, throwable);