Jacoco coverage doesn't work with RobolectricTestRunner
Seems like related to https://github.com/jacoco/jacoco/pull/288. Need to investigate
From reading the linked issue, it looks like there are two options for getting this working:
- with gradle
2.13+, use jacoco0.7.6+; or - with older gradle, use jacoco
0.7.2
It's not clear to me how to change the jacoco version. Reading this plugin it looks like jacoco gets imported from android-build-tools. Looking at android examples, it looks like jacoco should be configurable in build.gradle like this:
jacoco {
toolVersion '0.7.6'
}
but I haven't got this working yet.
android {
jacoco {
version '0.7.6'
}
}
has no effect either.
Ah, the previous example was missing an equals sign. Should have read:
android {
jacoco {
version = '0.7.6'
}
}
With this, I get the following error:
It is no longer possible to set the Jacoco version in the jacoco {} block.
To update the version of Jacoco without updating the android plugin,
add a buildscript dependency on a newer version, for example: buildscript{ dependencies {
classpath"org.jacoco:org.jacoco.core:0.7.4.201502262128" }}
However, adding this to build.gradle does not get tests working:
buildscript {
repositories {
...
}
dependencies {
...
classpath 'com.trickyandroid:jacoco-everywhere:0.2.1'
classpath 'org.jacoco:org.jacoco.core:0.7.6.201602180812'
}
}
The following seems to work:
buildscript {
...
configurations.all {
resolutionStrategy {
// use old jacoco so Robolectric test coverage is included in reports
force 'org.jacoco:org.jacoco.core:0.7.2.201409121644'
}
}
}
Same problem here. The @alxndrsn solution also works here.
Dear alxndrsn, I have met same issue like you. When I use JacocoEverywhere, coverage report doesn't include class which uses Robolectric. I have followed your above instruction but I still do not get coverage. Any updated source need ? Thank you
HI guys, tried the above mentioned fix for jacoco-everywhere from @alxndrsn , i get the following error " java.io.IOException: Incompatible version 1007.".
Please let me know if there is any other resolution for the same.
Thanks in advance