Support JaCoCo aggregated reports in test coverage visualization
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Proposal
Add support for JaCoCo aggregated reports in test coverage visualization.
Follows #227345 (closed) (and mentionned in #479804 (comment 2116912208)).
The current process works great in multi module projects if there are multiple JaCoCo reports, one in each module (see #227345 (comment 2059938471)).
-
module1target/jacoco-report/jacoco.xml
-
module2target/jacoco-report/jacoco.xml
For my projects, I have a different architecture. I have a report module that aggregate reports into a single one.
module1module2-
report(includesmodule1andmodule2)target/jacoco-report/jacoco.xml
The HTML report looks like this:
Reproducer
See project https://gitlab.com/jdussouillez/gitlab-jacoco-report-aggregate
-
PR #2: Test coverage visualization works because I use both
module1andmodule2reports and not the one aggregated. code
Reports
Here the structure of a report for a single module:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.1//EN" "report.dtd">
<report name="myapp-module1">
<package name="com/gitlab/jdussouillez/module1">
<!-- [...] -->
</package>
<!-- [...] -->
</report>
And for an aggregate:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.1//EN" "report.dtd">
<report name="myapp">
<group name="myapp-module1">
<package name="com/gitlab/jdussouillez/module1">
<!-- [...] -->
</package>
<!-- [...] -->
</group>
<group name="myapp-module2">
<package name="com/gitlab/jdussouillez/module2">
<!-- [...] -->
</package>
<!-- [...] -->
</group>
<!-- [...] -->
</report>
Implementation Guide
Cases to handle
- If the
<group>tag'snameattr always contains the root dir's name, e.g. the directory names at the root of your projectmyapp-module1,myapp-module2,it allows us to infer the file in the edge case of having 2 files with identical paths, aside from their root dirs.
e.g. module-1/src/main/java/com/gitlab/jdussouillez/acme, my-app-module-2/src/main/java/com/gitlab/jdussouillez/acme
- If the
<group>tag'snameattr doesn't contain the root dir's name, we can't support the above case and it will be a limitation to add to the docs.
We need to confirm with the JaCoCo maintainers if the group can be customized and if it is always populated when using the report-aggregate goal on the maven config.


