Jacoco exec file size not optimal. code coverage not happening properly


(Rishi Goel) #1

We are using jacoco plugin with build.gradle for an android app. We are getting .exec file but it is just 49KB which I reckon is too small. We are using gradle 3.3.1. We executed unit tests using the following command:

./gradlew testArm7DebugUnitTest

testArm7DebugUnitTest.exec is getting generated in build/jacoco directory but like I said it seems too small so when I use this .exec file to report to Sonar, it is showing just 0.2% coverage which is way too less than expected.


(Rishi Goel) #2

Folks, please suggest. We are deep down in waters so would really appreciate some help. Thanks.


(davidmichaelkarr) #3

This is not going to be a gradle problem. The JaCoCo exec file is a binary file. A file size of 49kb is not surprising at all. Pursue your issues in the JaCoCo forum, not here.

I have experience with using JaCoCo in a Maven build, and I would imagine it would work similarly in Gradle. The generated HTML report you’ll get in each project of a multiproject build will only show coverage for the classes in that project, so if your “unit tests” are not true unit tests, your reported coverage may well be much less than the actual coverage. You’d have to use the JaCoCo “merge” and “aggregate-report” (or “report-aggregate”?) goals to see a more complete view.