test-reporter
test-reporter copied to clipboard
Add support for Jacoco report output using the report-aggregate goal in a Maven multi-module project
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.
+1 (although a gradle android project)
Any news here?
+1
+100