quarkus
quarkus copied to clipboard
Jacoco coverage across jUnit and @QuarkusTest not working
Describe the bug
Wen having plain jUnit tests and @QuarkusTests side by side, the jacoco coverage is missing the coverage from the jUnit test. This behaviour still exists after applying the configuration suggested by quarkus: https://quarkus.io/guides/tests-with-coverage#coverage-for-tests-not-using-quarkustest
Expected behavior
The jacoco coverage report should respect the jUnit test and the @QarkusTest coverage
Actual behavior
Only the @Quarkus coverage is included in the jacoco coverage report
How to Reproduce?
Sample repository: https://github.com/HerrDerb/quarkus-jacoco-issue
- Run
./mvnw clean install - Open
/target/jacoco-report/org.acme/index.html
Output of uname -a or ver
No response
Output of java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
No response
Build tool (ie. output of mvnw --version or gradlew --version)
No response
Additional information
No response
Any news about this issue?
Is it recomendet to only use @QuarkusTest tests for beans and not normal unit tests if possible?
I was experiencing this issue.
Changing the jacoco-maven-plugin version to be the same as the jacoco version imported by quarkus, seems to have fixed it.
Unfortunately, it seems this has to be manually synced. Maybe it helps.
I've been facing the same problem about this topic in my project. I have the 0.8.7 jacoco version set in my pom, but the issue still happening.
I'm experiencing the same issue as @HerrDerb . Unfortunately, the workaround proposed by @darraghc345 does not seem to help in my case. I'm using Quarkus 2.13.0 and JaCoCo 0.8.8.
@HerrDerb I generated jacoco report based on your sample project, I got both coverage (junit + quarkus) :

GreetingService = Quarkus ByeService = jUnit
I must have had some wierd configuration. In our new project it also does work. I'll close this issue. If it does not work, it's most probalby because of a bad configuration.
I know that this issue is already closed. But I just experienced the exact same problem.
Quarkus 2.14.2, Jacoco 0.8.8.
None of the advice given here helped for me.
In the end, I found that, at the beginning of the integration tests, Quarkus threw away target/jacoco-quarkus.exec and recreated it from scratch. So, all the coverage from the unit tests was lost by design.
What helped for me was adding quarkus.jacoco.reuse-data-file to my application.yml and setting it to true (defaults to false).
I guess this hint should be added to the Quarkus documentation that most of the people relied on before coming here.
I am also facing the same issue but its intermittent. Like on one run it shows proper coverage but on the next run it doesn't show unit test coverage. None of the above shared solution have worked for me. cc: @cescoffier
Same issue. Using quarkus 2.16.
I've fixed it like this in my pom.xml
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${versions.jacoco}</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<exclClassLoaders>*QuarkusClassLoader</exclClassLoaders>
<destFile>${project.build.directory}/jacoco-quarkus.exec</destFile> ----> this is the fix
<append>true</append>
</configuration>
</execution>
<execution>
<id>generate-code-coverage-report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
Really, strange that I had to change that line, since this pom.xml was a copy/paste from another project where the unit tests do get covered by Jacoco. And there the line was ${project.build.directory}/jacoco.exec.
And btw, I'm using Quarkus 3.2.8.Final & jacoco 0.8.11.
I've fixed it like this in my pom.xml
<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>${versions.jacoco}</version> <executions> <execution> <id>default-prepare-agent</id> <goals> <goal>prepare-agent</goal> </goals> <configuration> <exclClassLoaders>*QuarkusClassLoader</exclClassLoaders> <destFile>${project.build.directory}/jacoco-quarkus.exec</destFile> ----> this is the fix <append>true</append> </configuration> </execution> <execution> <id>generate-code-coverage-report</id> <phase>test</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin>Really, strange that I had to change that line, since this pom.xml was a copy/paste from another project where the unit tests do get covered by Jacoco. And there the line was
${project.build.directory}/jacoco.exec.And btw, I'm using Quarkus 3.2.8.Final & jacoco 0.8.11.
Hey mate can you please share that are you able to generate the unit and integration test report separately, if so can you please provide the GitHub link for the same, I am struggling to find these same problem
I've fixed it like this in my pom.xml
<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>${versions.jacoco}</version> <executions> <execution> <id>default-prepare-agent</id> <goals> <goal>prepare-agent</goal> </goals> <configuration> <exclClassLoaders>*QuarkusClassLoader</exclClassLoaders> <destFile>${project.build.directory}/jacoco-quarkus.exec</destFile> ----> this is the fix <append>true</append> </configuration> </execution> <execution> <id>generate-code-coverage-report</id> <phase>test</phase> <goals> <goal>report</goal> </goals> </execution> </executions> </plugin>Really, strange that I had to change that line, since this pom.xml was a copy/paste from another project where the unit tests do get covered by Jacoco. And there the line was
${project.build.directory}/jacoco.exec.And btw, I'm using Quarkus 3.2.8.Final & jacoco 0.8.11.
Didn't work here :(