3

We have a Maven project which has submodules. There is one parent pom.xml and each and every sub projects are made into a war file. Each and every submodule has unit test cases and reports generated from Jacoco.

The existing reports show unit test coverage of individual modules but we need to provide integration test-wide code coverage on Tomcat. What we did was we installed jacoco agent in Tomcat folder and configured it to to generate jacoco.exec. When I import jacoco.exec using EclEmma plugin we see the code coverage.

Is there any way to generate report from standalone jacoco.exec without source code?

kryger
  • 12,906
  • 8
  • 44
  • 65
svs teja
  • 957
  • 2
  • 22
  • 43

2 Answers2

5
  1. Download Jacoco agent Zip file from the following URL: https://www.jacoco.org/jacoco/ select the version that suits your needs.

  2. Create folder with suitable name, I have mine located at "C:\jacoco". Extract the contents of the Zip file there.

  3. Open CMD and go to C:\jacoco

  4. Use the following command:

    java -jar jacococli.jar report --classfiles path/of/the/class/files path/of/the/.exec file --html html/report/location --name nameOfTheReport

Note:
1. -jar : I have kept jacococli.jar in Jacoco.
2. --classfiles : Path of the compiled java files.
3. Path of the exec file.
4. --name : Name of HTML report Title (Heading)

  1. Java code coverage report will be generated at your mentioned location.
ramayac
  • 5,173
  • 10
  • 50
  • 58
Imran Tamboli
  • 91
  • 1
  • 5
1

Jacoco .exec files use a very optimised file format that contain compact bit sets of which checkpoints have been executed and which have not been executed, but contain no informations about line numbers.

So, to generate any report, .exec files need to be applied to class files, that contains line numbers as debug informations.

Class files are enough to produce xml reports, while also sources are needed to produce html reports (for the sake of generating html pages with coloured lines).

Most Jacoco tools to generate reports allow you to specify where to find classes and sources to properly generate reports, so if you can download those exec file to a develop machine where there are also classes and sources, you will be able to generate reports.

Simone Gianni
  • 11,426
  • 40
  • 49