I am trying to use the jacoco maven plugin to report test coverage for
integration tests. There are a two related issues that complicate this:
* This is a multi module project.
* The primary code and integration tests are in separate modules. The
integration test module has no classes in src/main.
* The primary module is shaded and dependencies are relocated [1]. The
bytecode in primary-module/target/classes is normal, but in
primary-module/target/my-module.jar references to (for example) `import
com.example.Foo;` have been rewritten to `import
vendor.com.example.Foo`. The integration tests depend on the primary
module, and thus use the shaded jar with relocations (the intent was in
part to have the integration tests also verify that nothing went awry
with the shading process).
* I want coverage information for my classes, not the shaded dependencies.
I believe this is similar to other issues with modified classes. I
tried configuring jacoco for both unit and integration tests [2] and
then unpacking the modified class files [3] before running the
integration tests. When run through maven, all classes report zero
coverage for integration tests. Trying to debug what was in the exec
file if not coverage information I build the cli from master.
Running (in the integration test directory):
java -jar jacococli.jar report target/jacoco-it.exec \
--classfiles target/classes --html foo \
--sourcefiles ../java-manta-client/src/main/java/
Appears to work (in that the report displays nice green coverage
information. I can't figure out how that invocation is different from
what maven is doing. I tried running with a SNAPSHOT plugin to no avail.
Questions:
* What am I doing different in maven from the working cli invocation?
* If the above worked through maven, is there a way to override
"sourcefiles" for the maven report?
* Is there a better overall approach to this problem than this
specific hack? I had started with the report-aggregate goal, but could
not figure out a way around not coverage reported with: [WARNING]
Classes in bundle 'java-manta-client' do no match with execution data.
For report generation the same class files must be used as at runtime.
[1]
https://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation.html
[2]
https://github.com/cburroughs/java-manta/blob/inter-cov/pom.xml#L443-L492
[3]
https://github.com/cburroughs/java-manta/blob/inter-cov/java-manta-it/pom.xml#L117-L154