The android gradle plugin has a built-in function.
Just set the parameter to a testCoverageEnabled
value true
in the file build.gradle
:
android {
buildTypes {
debug {
testCoverageEnabled = true
}
}
}
Then use:
./gradlew connectedCheck
or
./gradlew createDebugCoverageReport
It issues a test report in the module directory:
/build/outputs/reports/coverage/debug/
Just open index.html
Example:
source
share