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 8674b8b29478e..1ecc7379b9946 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 @@ -889,6 +889,21 @@ public void interceptTestMethod(Invocation invocation, ReflectiveInvocatio invocation.skip(); } + @Override + public void interceptDynamicTest(Invocation invocation, ExtensionContext extensionContext) throws Throwable { + if (runningQuarkusApplication == null) { + invocation.proceed(); + return; + } + var old = Thread.currentThread().getContextClassLoader(); + try { + Thread.currentThread().setContextClassLoader(runningQuarkusApplication.getClassLoader()); + invocation.proceed(); + } finally { + Thread.currentThread().setContextClassLoader(old); + } + } + @Override public void interceptTestTemplateMethod(Invocation invocation, ReflectiveInvocationContext invocationContext, ExtensionContext extensionContext) throws Throwable {