1

What is the advantage of using --sourcefiles flag while generating jacoco reports using jacoco cli jar vs when not using it?

Reference: https://www.jacoco.org/jacoco/trunk/doc/cli.html

Task: Report

DolphinJava
  • 2,682
  • 1
  • 23
  • 37

1 Answers1

3

To see the difference you can try with and without this option. For example:

Given following src/org/example/Example.java

package org.example;

class Example {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

After compilation and execution by

javac src/org/example/Example.java -d classes
java -javaagent:jacoco-0.8.5/lib/jacocoagent.jar -cp classes org.example.Example

Generation of report without --sourcefiles

java -jar jacoco-0.8.5/lib/jacococli.jar report jacoco.exec --classfiles classes --html report_without_sourcefiles

will produce report in directory report_without_sourcefiles where you can not see source file

report

report for package

report for class


While generation of report with --sourcefiles

java -jar jacoco-0.8.5/lib/jacococli.jar report jacoco.exec --classfiles classes --sourcefiles src --html report_with_sourcefiles

will produce report in directory report_with_sourcefiles where you can see source file

report

report for package

report for class

report for source file

Godin
  • 9,801
  • 2
  • 39
  • 76