JaCoCo aggregated code coverage report is not generated for additional test suite

I am using Gradle 8.13. I have a Gradle project with multiple subprojects.

All subprojects contain the default Java test task. Some projects have an additional test task called integTest.

I have now added the JaCoCo Report Aggregation Plugin. I have followed Gradle’s example with a standalone utility project.

For each test suite I want to create a coverage report. I have configured the JaCoCo Report Aggregation Plugin like this:

reporting {
    reports {
        val testCodeCoverageReport by creating(JacocoCoverageReport::class) {
            testSuiteName = "test"
        }
        val integTestCodeCoverageReport by creating(JacocoCoverageReport::class) {
            testSuiteName = "integTest"
        }
    }
}

Unfortunately, now JaCoCo coverage report is generated for the integTest test suite. The following message is printed:

Task :code-coverage-report:integTestCodeCoverageReport SKIPPED
Skipping task ‘:code-coverage-report:integTestCodeCoverageReport’ as task onlyIf ‘Any of the execution data files exists’ is false.

I have made sure that the integTest tests are executed before I try to generate the report. And when I look into the subprojects, JaCoCo .exec files for both test suites exist:

subproject/build/jacoco/integTest.exec
subproject/build/jacoco/test.exec

Why is the code coverage report not created for the integTest test suite, even though JaCoCo execution files exist for it?

There is no need to “make sure that the integTest tests are executed before”.
If everything is set up properly, the tests would be run automatically if you trigger the report generation iirc.

Can you share an MCVE if what you tried?

Hi Vampire!

I have created an MCVE here: GitHub - haroldlbrown/gradle-aggregate-report-bug

When one runs the ./gradlew build command, no aggregated code coverage is created for the integTest tests.

Because you just created a custom Test task, not a proper test suite.
The jacoco plugin automatically creates the necessary outgoing variants for JVM test suite you create that provide the JaCoCo results to consumers like the JaCoCo Report Aggregation plugin.
But as you did not create a proper JVM test suite, but just a manual task of type Test this configuration is missing.
That you configure the testSuiteName for the aggregation but not create any “test suite” could have been a hint. :wink:
So best and easiest is, you define a proper test suite instead of a manual task of type Test then you also save 98.7 % of the boilerplate code you wrote there, as by defining the test suite, you automatically get all you need, like the source set, the task, the configurations, the setup for the aggregation, …

If for some reason you prefer to do all the legwork yourself, you also have to replicate what the JaCoCo plugin would have done for you and create the outgoing variant for the JaCoCo results.

Hi Vampire.

OK, that makes sense!

Thank you very much.

1 Like