Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract readable format report from jacoco.exec?

Tags:

jacoco

I have a jacoco-agent generated file of my Maven project (Java), named jacoco.exec. How can I convert this file into human readable format? (HTML/XML).

like image 729
avy Avatar asked Dec 08 '16 08:12

avy


2 Answers

I believe that this is described in official JaCoCo documentation. In particular there is jacoco-maven-plugin goal "report" and example of its usage.

Starting from JaCoCo version 0.8.0 there is also Command Line interface. Here is an example of how to use it to produce HTML report from jacoco.exec, note that this also requires class files:

java -jar jacoco-0.8.1/lib/jacococli.jar report jacoco.exec --classfiles directory_with_classes --html directory_for_report
like image 188
Godin Avatar answered Dec 22 '22 00:12

Godin


In the Gradle world (for anyone who happened to stumble upon this question), use the JacocoReport task, documented here.

The configured task would look something like this:

jacocoTestReport {
  reports {
    html.enabled = true
    html.destination "${buildDirectory}/coverage/report/html"

    xml.enabled = true
    xml.destination "${buildDirectory}/coverage/report/xml"
  }
  executionData = files("path/to/jacoco.exec")
}
like image 42
Pranav Avatar answered Dec 21 '22 22:12

Pranav