I generated a code coverage report from jacoco, which is jacoco.exec. But I don\'t know how to use it ...
The way I generated it is through command line:
Per this thread you can't use your generated jacoco.exec directly to produce a report. You can download Jacoco's sample build.xml and use it to produce a report, instead. You'll need to make these changes to build.xml: set the the paths to
I also changed the default target to "report". Then run it by typing "ant" and your reports will be generated.
If you use maven, use the report-aggregate goal.
See link below:
report aggregate maven goal
This is a snippet from my maven pom.xml file
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report-aggregate</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions
The csv report file was generated under: site/jacoco/jacoco.csv
For Eclipse users, you can simply use EclEmma jacoco plugin in Eclipse. Window > Show View > Coverage (of course you must install the plugin first). In the Coverage window, Right click > Import >..... Select the exec file (or other nice methods), select your source code, then see. You can also export the result to html file.
This answer would be similar to @Evans Y. One can generate HTML files (over here in report directory) and XML file (named as cov) with the help of below command from Jacoco documentation.
java -jar lib/jacococli.jar report jacoco.exec \
--classfiles C:\Users\severalOtherDirectories\YourProject\target\classes \
--html ./report --xml cov.xml
HTML Report: This report would be able to show total number of lines covered/uncovered at the Class or method level, but won't be able to show what actual line(s) are covered/uncovered in the same.
XML file: After plugging this generated file in the project and simply using VS code coverage extension (I prefer coverage gutters) , one can visualize line-by-line status in the editor itself.