test-reporter icon indicating copy to clipboard operation
test-reporter copied to clipboard

Add support for Jacoco report output using the report-aggregate goal in a Maven multi-module project

Open io-timeout opened this issue 6 years ago • 3 comments

When working with JaCoCo in a maven multi-module project it is necessary to use the report-aggregate goal to create an aggregated test coverage report.

The format of the jacoco.xml file in this case is a little different to the version produced when using the report goal as JaCoCo outputs an additional <group name="api-common"> element as the parent of the <package> element which the coverage formatter is expecting. The purpose of the<group>element is to state which module contains the code described by the child elements of the group.

A sample project using the report-aggregate goal can be found here: https://github.com/DEFRA/data-returns-api-platform

As a workaround I was able to strip <group> elements from the xml file before running cc-reporter as follows:

sed -e 's/<[\/]\?group[^>]*>//g' target/site/jacoco-aggregate/jacoco.xml > target/site/jacoco-aggregate/jacoco-codeclimatecompat.xml
JACOCO_SOURCE_PATH="api-common/src/main/java api-example/src/main/java" ./cc-test-reporter format-coverage target/site/jacoco-aggregate/jacoco-codeclimatecompat.xml --input-type jacoco
./cc-test-reporter upload-coverage

It would be nice (in the short term) if the codeclimate reporter could just ignore <group> elements as allowing multiple items in the JACOCO_SOURCE_PATH env-var means this would work quite nicely. In the longer term the reporter could potentially use the content of the <group> element to auto-discover the correct source paths to use.

io-timeout avatar Nov 19 '18 20:11 io-timeout

+1 (although a gradle android project)

Any news here?

FranziskusW avatar Jun 17 '20 12:06 FranziskusW

+1

aledevops avatar Jul 07 '22 12:07 aledevops

+100

kbirger avatar Nov 14 '23 21:11 kbirger