quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.87k stars 2.71k forks source link

Jacoco doesn't count coverage for @QuarkusTest tests #39075

Open psdorofeev opened 9 months ago

psdorofeev commented 9 months ago

Describe the bug

Hi, I have a gradle quarkus project which consists of 2 modules: api and utils. api module contains test classes for both utils and api modules (some of them are marked as @QuarkusTest). api's build gradle is configured according to https://quarkus.io/guides/tests-with-coverage#quarkus-jacoco-jacoco-config_quarkus-jacoco-includes: 1) it has gthe following plugins: plugins { id 'java' id 'io.quarkus' id 'jacoco' id 'org.kordamp.gradle.jandex' version '1.1.0' } 2) it has dependency testImplementation("io.quarkus:quarkus-jacoco") 3) for non QuarkusTests it has: test { environment("DOCKER_HOST", System.getenv("TEST_DOCKER_URL")) systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager" systemProperty("quarkus.test.profile", "test-${buildDatabaseKind}") finalizedBy jacocoTestReport jacoco { excludeClassLoaders = ["*QuarkusClassLoader"] destinationFile = layout.buildDirectory.file("jacoco-quarkus.exec").get().asFile } jacocoTestReport.enabled = false }

There are 3 test classes:

Project structure looks like: image

And jacoco report doesn't take into account test classes marked as @QuarkusTest: image

If I change CommonTest class and add @QuarkusTest annotation (despite it is actually not a Quarkus test), then report looks like: image

And everything works fine if I don't have submodules in my project.

Expected behavior

Jacoco should take into account QuarkusTest classes

Actual behavior

Jacoco doesn't take into account QuarkusTest classes

How to Reproduce?

Create project like in the description and run 'gradle clean build'

Output of uname -a or ver

No response

Output of java -version

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

psdorofeev commented 9 months ago

Quarkus version 3.2.9.Final

psdorofeev commented 9 months ago

I also noticed that it works this way only if default build directory is changed in build.gradle: buildDir = file("${rootProject.buildDir}/${project.name}")