We are trying to report code coverage of tests against a pre-packaged JAR file using JaCoCo. To do this we start the JAR file using java -jar
with the additional argument:
-javaagent:${project.basedir}/tools/jacocoagent.jar=output=tcpserver,port=${jacoco.port}
JaCoCo's Maven plugin is configured to then dump the execution file and report the results:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<executions>
<execution>
<id>dumpData</id>
<phase>post-integration-test</phase>
<goals>
<goal>dump</goal>
</goals>
<configuration>
<address>localhost</address>
<port>${jacoco.port}</port>
<destFile>target/jacoco.exec</destFile>
</configuration>
</execution>
<execution>
<id>report</id>
<phase>verify</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>target/jacoco.exec</dataFile>
</configuration>
</execution>
</executions>
</plugin>
This works to the point that a jacoco.exec
file is generated which has a non-zero size (~350kB).
But the report shows no coverage at all. Following the "Sessions" link I can see the classes in the JAR listed, but the report's home page shows this:
Based on the logs we have the code seems to be exercised. Is there a step missing in the JaCoCo setup or should this work?