From 735ff945ac2175d0138f2822a7f691886355efad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Vav=C5=99=C3=ADk?= Date: Thu, 19 Oct 2023 10:34:26 +0200 Subject: [PATCH] Log exceptions thrown when executing debug of FW tests --- .../test/debug/SureFireDebugProvider.java | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/quarkus-test-core/src/main/java/io/quarkus/test/debug/SureFireDebugProvider.java b/quarkus-test-core/src/main/java/io/quarkus/test/debug/SureFireDebugProvider.java index 8cfd0ad4b..b79ef5dfe 100644 --- a/quarkus-test-core/src/main/java/io/quarkus/test/debug/SureFireDebugProvider.java +++ b/quarkus-test-core/src/main/java/io/quarkus/test/debug/SureFireDebugProvider.java @@ -56,30 +56,37 @@ public Iterable> getSuites() { @Override public RunResult invoke(Object o) throws TestSetFailedException, ReporterException, InvocationTargetException { - var bootstrap = new QuarkusScenarioBootstrap(); - var testContext = new TestContext.TestContextImpl(findTestClass(), Set.of()); - var testClassInstance = instantiateTestClass(); - - bootstrap.beforeAll(testContext); - invokeTestBeforeAll(testClassInstance); - if (runTests) { - // beforeEach methods are called before test - runTests(testClassInstance, bootstrap, testContext); - } else { - invokeTestBeforeEach(testClassInstance); - bootstrap.beforeEach(testContext, findTestMethod()); - } + try { + var bootstrap = new QuarkusScenarioBootstrap(); + var testContext = new TestContext.TestContextImpl(findTestClass(), Set.of()); + var testClassInstance = instantiateTestClass(); + + bootstrap.beforeAll(testContext); + invokeTestBeforeAll(testClassInstance); + if (runTests) { + // beforeEach methods are called before test + runTests(testClassInstance, bootstrap, testContext); + } else { + invokeTestBeforeEach(testClassInstance); + bootstrap.beforeEach(testContext, findTestMethod()); + } - waitTillUserWishesToExit(); + waitTillUserWishesToExit(); - if (!runTests) { - bootstrap.afterEach(); - invokeTestAfterEach(testClassInstance); + if (!runTests) { + bootstrap.afterEach(); + invokeTestAfterEach(testClassInstance); + } + invokeTestAfterAll(testClassInstance); + bootstrap.afterAll(); + + return noTestsRun(); + } catch (Throwable t) { + // this needs to be done, because the exception and message are not logged, + // instead, generic exception is provided + LOG.error("Execution failed with following exception", t); + throw t; } - invokeTestAfterAll(testClassInstance); - bootstrap.afterAll(); - - return noTestsRun(); } private Object instantiateTestClass() throws InvocationTargetException {