Gradle plugin which allows to generate Jacoco coverage report for both integration & unit tests
This plugin is not maintained anymore and is deprecated!
Android plugin has built-in support for generating test coverage report:
android {
buildTypes {
debug {
testCoverageEnabled = true
}
}
}
However, this report only shows test coverage for your integration tests (aka UI tests, aka those ones you run with ./gradlew connectedCheck
).
But what we really want - is to see test coverage report for both integration AND unit test suites!
jacoco-everywhere plugin does just that!
- Enable code coverage like you normally would for your integration tests:
android {
buildTypes {
debug {
testCoverageEnabled = true
}
}
}
- Add
jacoco-everywhere
dependency to Android module buildscript and applyjacoco-everywhere
plugin:build.gradle
:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.trickyandroid:jacoco-everywhere:0.2.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'jacoco-everywhere'
-
execute
./gradlew connectedCheck
from your command line -
Observe Jacoco test coverage report in
<your_project_dir>/<android_module>/build/reports/coverage/debug/index.html