安卓jacoco覆盖空与摇篮 [英] android jacoco coverage empty with gradle
问题描述
我试图让jacoco创造code覆盖率报告我的Android测试项目。我有以下的build.gradle:
I'm trying to make jacoco create a code coverage report for my android test project. I have the following in build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'jacoco'
...
jacoco {
toolVersion = "0.7.1.201405082137"
}
...
android {
buildTypes {
release {
}
debug {
testCoverageEnabled true
}
}
}
当我运行gradlew -i createDebugCoverageReport,我得到一个覆盖报告,但它是空的。在摇篮执行结束如下:
when I run gradlew -i createDebugCoverageReport, I get a coverage report, but it's empty. the end of the gradle execution is as follows:
:androidTest:connectedAndroidTest (Thread[main,5,main]) completed. Took 2 mins 36.951 secs.
:androidTest:createDebugCoverageReport (Thread[main,5,main]) started.
:androidTest:createDebugCoverageReport
Executing task ':androidTest:createDebugCoverageReport' (up-to-date check took 0.006 secs) due to:
Output file /home/akos/src/androidTest/build/outputs/reports/coverage/debug has changed.
Output file /home/akos/src/androidTest/build/outputs/reports/coverage/debug/index.html has been removed.
Output file /home/akos/src/androidTest/build/outputs/reports/coverage/debug/.resources/package.gif has been removed.
[ant:reportWithJacoco] Loading execution data file /home/akos/src/androidTest/build/outputs/code-coverage/connected/coverage.ec
[ant:reportWithJacoco] Writing bundle 'debug' with 3 classes
:androidTest:createDebugCoverageReport (Thread[main,5,main]) completed. Took 0.215 secs.
BUILD SUCCESSFUL
Total time: 4 mins 53.467 secs
而事实上,上述提及的coverage.ec文件是空的(0长度)
and indeed, the coverage.ec file referenced above is empty (of 0 length)
在目录中生成/中间体/覆盖,仪表类/,我似乎有仪表类文件
in the directory build/intermediates/coverage-instrumented-classes/ , I seem to have the instrumented class files
这是与摇篮2.1
我是什么做错了吗?
推荐答案
Jacoco应该是机器人
关闭和jacoco插件声明里面是没有必要的:
Jacoco should be inside of the android
closure and the jacoco plugin declaration is not necessary:
apply plugin: 'com.android.application'
...
android {
buildTypes {
release {
}
debug {
testCoverageEnabled true
}
}
jacoco {
toolVersion = "0.7.1.201405082137"
}
}
这篇关于安卓jacoco覆盖空与摇篮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!