Version info:
Gradle 2.2.1
Android Gradle plugin 1.0.1
Robolectric Gradle plugin 0.14.1
JUnit 4.10
Robolectric 2.4
Setting up a simple test using a configuration like:
apply plugin: 'jacoco'
jacoco.toolVersion = project.property('jacocoVersion')
and running my unit tests with:
$ ./gradlew -PjacocoVersion=0.7.1.+ clean :testDebug :jacocoTestDebugReport
...
$ ls -l build/jacoco/testDebug.exec
-rw-r--r--+ 1 jhansche staff 278218 Feb 26 16:45 build/jacoco/testDebug.exec
$ strings build/jacoco/testDebug.exec | wc -l
4325
This all works correctly, and I get a proper JaCoCo report generated. Changing nothing else but the toolVersion
, however, breaks the execution data that is gathered:
$ ./gradlew -PjacocoVersion=0.7.4-SNAPSHOT clean :testDebug :jacocoTestDebugReport
...
$ ls -l build/jacoco/testDebug.exec
-rw-r--r--+ 1 jhansche staff 36910 Feb 26 16:56 build/jacoco/testDebug.exec
$ strings build/jacoco/testDebug.exec | wc -l
639
You can see that the execution data file is much smaller, and contains far fewer strings. Looking at the "Sessions" link in the top-right of the HTML report lists only one class from my application's package (the Android app's R$styleable
class). The majority of the classes listed are in one of the org.gradle
, org.junit
, or org.robolectric
packages. Using 0.7.1, it included all the android.**
classes, and more importantly, the classes from my application.
However, when I set the test.jacoco.classDumpFile = file("${project.buildDir}/jacoco/dump")
property, I do see most of my application's (tested) classes listed in that directory -- they just don't show up in the execution data file.
One other difference that I notice in the dump/
directory (for a single example test class):
0.7.1:
build/jacoco/dump//com/example/MyClass.class
build/jacoco/dump//com/example/MyClassTest.class
0.7.4:
build/jacoco/dump//com/example/MyClass.9b700a23ba643d32.class
build/jacoco/dump//com/example/MyClassTest.22115a9aa9d0d3ee.class
I'm in a difficult position as now I am forced to use two different versions of JaCoCo: 0.7.1 with Robolectric+JUnit to get coverage of unit tests on the local JVM; and 0.7.3+ with Calabash to get coverage of instrumentation tests running on the device's runtime -- I am forced to update to 0.7.3 in order to allow support for the Android ART runtime, as otherwise the instrumented classes cannot be installed on a Lollipop device.
What other information can I provide to help track down what is going wrong here? If it's not a bug in JaCoCo, then who is to blame? (I realize there is a very long list of potential candidates for where it should be fixed).
type: bug :bug: component: core