diff --git a/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusUnitTest.java b/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusUnitTest.java index 622d1898dc261..05d45ae4e1e63 100644 --- a/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusUnitTest.java +++ b/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusUnitTest.java @@ -275,7 +275,12 @@ private void runExtensionMethod(ReflectiveInvocationContext invocationCo try { newMethod.setAccessible(true); newMethod.invoke(actualTestInstance, invocationContext.getArguments().toArray()); - } catch (IllegalAccessException | InvocationTargetException e) { + } catch (InvocationTargetException e) { + if (e.getCause() instanceof RuntimeException) { + throw (RuntimeException) e.getCause(); + } + throw new RuntimeException(e.getCause()); + } catch (IllegalAccessException e) { throw new RuntimeException(e); } } diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java index aa8901e03a242..2b2213a41ceb5 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java @@ -351,7 +351,12 @@ private void runExtensionMethod(ReflectiveInvocationContext invocationCo } newMethod.setAccessible(true); newMethod.invoke(actualTestInstance, invocationContext.getArguments().toArray()); - } catch (Exception e) { + } catch (InvocationTargetException e) { + if (e.getCause() instanceof RuntimeException) { + throw (RuntimeException) e.getCause(); + } + throw new RuntimeException(e.getCause()); + } catch (IllegalAccessException | ClassNotFoundException e) { throw new RuntimeException(e); } }