Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use jacoco.exec report

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:

java -javaagent:/path/to/jacocoagent.jar=include=some.package.*,output=file org.junit.runner.JUnitCore some.package.ClassTest 

Then I got the jacoco.exec report. All I need is just the number of percentage, and I am using command line only. Is there a way to convert this report to a readable txt file?

Thanks all

like image 280
wlhee Avatar asked Jul 31 '13 14:07

wlhee


People also ask

How do I get my JaCoCo code coverage report?

To get code coverage reports in a Maven project, we first need to set up the JaCoCo Maven plugin for that project. By integrating the JaCoCo plugin, the results of the code coverage analysis can be reviewed as an HTML report. The current version of the JaCoCo-Maven plugin can be downloaded from the MVN Repository.

What is JaCoCo report?

Jacoco is an open source project, which can be used to check production code for test code coverage. It creates reports and integrates well with IDEs like the Eclipse IDE. Integration is also available for other IDEs and continuous integration environments.


2 Answers

In IntelliJ Idea from the menu select Analyze > Show Coverage data. In the new window press the + button and select your .exec file. The test coverage results will appear in the editor Coverage tab.

Update:

In the latest version of Intellij Idea the menu has been moved to Run > Show Code Coverage Data

like image 102
Roberto Avatar answered Sep 30 '22 07:09

Roberto


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.

like image 44
Loc Phan Avatar answered Sep 30 '22 06:09

Loc Phan