Skip to content

Running Quarkus tests with the CLI fails to generate enhanced JUnit report #85

Description

@bitcoder

While running Quarkus tests, annotated with @QuarkusTest, while using mvn quarkus:test, it produces an exception as seen ahead.
However, if we run the tests using mvn testall tests are executed fine and the enhanced JUnit XML report is produced by the xray-junit-extensions library.
This seems to the fact that there is a "conflict" between Quarkus extension (i.e., TestExecutionListener) and the one from the xray-junit-extension (i.e., EnhancedLegacyXmlReportGeneratingListener); I'm not sure why it only is visible while running mvn quarkus:test... (?)
This is reproducible using this sample code in this repository .

From a preliminary analysis it seems that quarkus-junit boots the quarkus application and loads all classes.. and then it unloads them at the end of the execution of the tests, on its TestExecutionListener. Then, EnhancedLegacyXmlReportGeneratingListener from xray-junit-extensions is not able to get the method of the test method while trying to produce the JUnit XML report... because the classes are not loaded anymore and the code doesn't work.

$ mvn quarkus:test
[INFO] Scanning for projects...
[INFO] 
--
Running tests for the first time
Press [:] for the terminal, [h] for more options>


2025-12-23 14:50:09,873 INFO  [io.quarkus.test] (Test runner thread) Running 1/1. Running: #JUnit Jupiter
2025-12-23 14:50:09,897 INFO  [io.quarkus.test] (Test runner thread) Running 1/1. Running: com.example.ExampleResourceTest#ExampleResourceTest
2025-12-23 14:50:10,416 INFO  [io.quarkus] (Test runner thread) xray-test 1.0-SNAPSHOT on JVM (powered by Quarkus 3.30.3) started in 2.983s. Listening on: http://localhost:8081
2025-12-23 14:50:10,420 INFO  [io.quarkus] (Test runner thread) Profile test activated. 
2025-12-23 14:50:10,422 INFO  [io.quarkus] (Test runner thread) Installed features: [cdi, rest, smallrye-context-propagation, vertx]
2025-12-23 14:50:10,441 INFO  [io.quarkus.test] (Test runner thread) Running 1/1. Running: com.example.ExampleResourceTest#testHelloEndpoint()
2025-12-23 14:50:11,633 INFO  [io.quarkus] (Test runner thread) xray-test(test application) stopped in 0.018s
2025-12-23 14:50:11,676 SEVERE [app.getxray.xray.junit.customjunitxml.EnhancedLegacyXmlReportGeneratingListener] (Test runner thread) Could not get test method from method source MethodSource [className = 'com.example.ExampleResourceTest', methodName = 'testHelloEndpoint', methodParameterTypes = ''] [Error Occurred After Shutdown]: java.lang.ClassNotFoundException: com.example.ExampleResourceTest
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528)
        at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:577)
        at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:524)
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:462)
        at java.base/java.lang.Class.forName(Class.java:453)
        at app.getxray.xray.junit.customjunitxml.XmlReportWriter.getTestMethod(XmlReportWriter.java:208)
        at app.getxray.xray.junit.customjunitxml.XmlReportWriter.getTestMethod(XmlReportWriter.java:201)
        at java.base/java.util.Optional.flatMap(Optional.java:289)
        at app.getxray.xray.junit.customjunitxml.XmlReportWriter.writeTestcase(XmlReportWriter.java:236)
        at app.getxray.xray.junit.customjunitxml.XmlReportWriter.writeTestsuite(XmlReportWriter.java:156)
        at app.getxray.xray.junit.customjunitxml.XmlReportWriter.writeXmlReport(XmlReportWriter.java:135)
        at app.getxray.xray.junit.customjunitxml.XmlReportWriter.writeXmlReport(XmlReportWriter.java:114)
        at app.getxray.xray.junit.customjunitxml.EnhancedLegacyXmlReportGeneratingListener.writeXmlReportSafely(EnhancedLegacyXmlReportGeneratingListener.java:188)
        at app.getxray.xray.junit.customjunitxml.EnhancedLegacyXmlReportGeneratingListener.writeXmlReportInCaseOfRoot(EnhancedLegacyXmlReportGeneratingListener.java:168)
        at app.getxray.xray.junit.customjunitxml.EnhancedLegacyXmlReportGeneratingListener.executionFinished(EnhancedLegacyXmlReportGeneratingListener.java:157)
        at org.junit.platform.launcher.core.CompositeTestExecutionListener.lambda$executionFinished$10(CompositeTestExecutionListener.java:74)
        at org.junit.platform.launcher.core.CompositeTestExecutionListener.lambda$notifyEach$21(CompositeTestExecutionListener.java:110)
        at org.junit.platform.commons.util.CollectionUtils.forEachInReverseOrder(CollectionUtils.java:263)
        at org.junit.platform.launcher.core.IterationOrder$2.forEach(IterationOrder.java:30)
        at org.junit.platform.launcher.core.CompositeTestExecutionListener.notifyEach(CompositeTestExecutionListener.java:108)
        at org.junit.platform.launcher.core.CompositeTestExecutionListener.executionFinished(CompositeTestExecutionListener.java:73)
        at org.junit.platform.launcher.core.ExecutionListenerAdapter.executionFinished(ExecutionListenerAdapter.java:57)
        at org.junit.platform.launcher.core.CompositeEngineExecutionListener.lambda$executionFinished$6(CompositeEngineExecutionListener.java:60)
        at org.junit.platform.launcher.core.CompositeEngineExecutionListener.lambda$notifyEach$13(CompositeEngineExecutionListener.java:82)
        at org.junit.platform.commons.util.CollectionUtils.forEachInReverseOrder(CollectionUtils.java:263)
        at org.junit.platform.launcher.core.IterationOrder$2.forEach(IterationOrder.java:30)
        at org.junit.platform.launcher.core.CompositeEngineExecutionListener.notifyEach(CompositeEngineExecutionListener.java:80)
        at org.junit.platform.launcher.core.CompositeEngineExecutionListener.executionFinished(CompositeEngineExecutionListener.java:59)
        at org.junit.platform.launcher.core.DelegatingEngineExecutionListener.executionFinished(DelegatingEngineExecutionListener.java:47)
        at org.junit.platform.launcher.core.StackTracePruningEngineExecutionListener.executionFinished(StackTracePruningEngineExecutionListener.java:46)
        at org.junit.platform.launcher.core.DelegatingEngineExecutionListener.executionFinished(DelegatingEngineExecutionListener.java:47)
        at org.junit.platform.launcher.core.OutcomeDelayingEngineExecutionListener.reportEngineOutcome(OutcomeDelayingEngineExecutionListener.java:69)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.executeEngine(EngineExecutionOrchestrator.java:233)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.failOrExecuteEngine(EngineExecutionOrchestrator.java:204)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:172)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:101)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:64)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:150)
        at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:63)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:109)
        at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:100)
        at org.junit.platform.launcher.core.DelegatingLauncher.execute(DelegatingLauncher.java:52)
        at org.junit.platform.launcher.core.InterceptingLauncher.lambda$execute$2(InterceptingLauncher.java:47)
        at org.junit.platform.launcher.core.ClasspathAlignmentCheckingLauncherInterceptor.intercept(ClasspathAlignmentCheckingLauncherInterceptor.java:25)
        at org.junit.platform.launcher.core.InterceptingLauncher.execute(InterceptingLauncher.java:46)
        at org.junit.platform.launcher.core.DelegatingLauncher.execute(DelegatingLauncher.java:52)
        at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:73)
        at io.quarkus.deployment.dev.testing.JunitTestRunner$2.run(JunitTestRunner.java:255)
        at io.quarkus.deployment.dev.testing.ModuleTestRunner$2.run(ModuleTestRunner.java:90)
        at io.quarkus.deployment.dev.testing.TestSupport.runInternal(TestSupport.java:469)
        at io.quarkus.deployment.dev.testing.TestSupport$3.run(TestSupport.java:389)
        at java.base/java.lang.Thread.run(Thread.java:1575)




--
All 1 test is passing (0 skipped), 1 test was run in 4775ms. Tests completed at 14:50:11.
Press [r] to re-run, [:] for the terminal, [h] for more options>

Relates with #84

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions