quarkusio / quarkus

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

Jacoco Report not generated when maven-surefire-plugin is added to parent pom #40944

Open hamburml opened 2 months ago

hamburml commented 2 months ago

Describe the bug

Most of our repos are structured as multi-module repos. Some modules are quarkus-services, some are only libs which are shared between the quarkus-services. Every module had the jacoco-maven-plugin and I want to migrate to the quarkus-jacoco plugin. Additionally we have a sonarqube instance which reports our test coverage.

I have some issues during migration (not finding tests for example) therefore I tried it with a minimal project setup, which can be found here: https://github.com/hamburml/multi-module-test-coverage and it works - for each module. After mvn verify I find all reports located in target/jacoco-report (which I think I will change to target/site because that is the defacto default location if I remember. I need to make sure that sonarqube finds the report).

But now I want to aggregate every report to a big "repository report". I used https://quarkus.io/guides/tests-with-coverage#working-with-multi-module-projects the following config, pasted it in the parent pom and after mvn verify all reports are gone.

Expected behavior

every module should have a target/jacoco-report folder and the parent target/coverage folder should be aggregated module reports.

Actual behavior

After

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <quarkus.jacoco.data-file>${maven.multiModuleProjectDirectory}/target/jacoco.exec</quarkus.jacoco.data-file>
                        <quarkus.jacoco.reuse-data-file>true</quarkus.jacoco.reuse-data-file>
                        <quarkus.jacoco.report-location>${maven.multiModuleProjectDirectory}/target/coverage</quarkus.jacoco.report-location>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>

is added to the parent pom all reports are gone

How to Reproduce?

  1. clone https://github.com/hamburml/multi-module-test-coverage
  2. mvn verify
  3. check reports
  4. add maven-surefire-plugin to parent-pom as shown in guide https://quarkus.io/guides/tests-with-coverage#working-with-multi-module-projects
  5. mvn verify
  6. reports gone

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

quarkus-bot[bot] commented 2 months ago

/cc @quarkusio/devtools (maven)

aloubyansky commented 2 months ago

@hamburml I just tried it and it worked. The reports are under multi-module-test-coverage/target/coverage.

hamburml commented 2 months ago

@aloubyansky So it is a replacement and the individual reports are gone? Is it 100% coverage? Will try again, lemme boot my machine :)

aloubyansky commented 2 months ago

With that config, this is the location

<quarkus.jacoco.report-location>${maven.multiModuleProjectDirectory}/target/coverage</quarkus.jacoco.report-location>

which is relative to the root dir of the multi module project.

hamburml commented 2 months ago

I may have overlooked that, now I have it too. Thanks! What is now strange: The coverage is 50%. If I remove the aggregated report it is 100% for the common module. The common module has next to one QuarkusTest one simple JUnit5 Test (without QuarkusTest Annotation).

image

edit

Nevertheless I would like to have the aggregated report and keep each module report. Also the Test for the GreetingResource is gone in the aggregated report, in service_A report its still there.