I\'m trying to get a test coverage report using Gradle Android plugin 0.10.2. But I still can\'t get a coverage report after running some tests. (connectedAndroidTest).
Gradle already has built-in support for generating test coverage reports and we don't need to create any additional configurations or add any plugins to generate test coverage report. Basically, the only thing we need to do, is to set testCoverageEnabled parameter to true in build.gradle file as follows:
android {
buildTypes {
debug {
testCoverageEnabled = true
}
}
}
Next, we can execute the following Gradle task from CLI:
./gradlew createDebugCoverageReport
On Windows, we can execute it like this:
gradlew.bat createDebugCoverageReport
Task will analyze code of our project in /src/main/java/ directory and unit tests placed in /src/androidTest/java/ directory.
After executing this task, we can find test coverage report in the following directory of the module:
/build/outputs/reports/coverage/debug/
When we open index.html file, we can see visual report from test coverage, which can be viewed in a web browser.
It looks as on the image below.
article about test coverage report in Android application http://blog.wittchen.biz.pl/test-coverage-report-for-android-application/