android jacoco覆盖空与gradle

前端之家收集整理的这篇文章主要介绍了android jacoco覆盖空与gradle前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试让jacoco为我的 android测试项目创建一个代码覆盖率报告.我在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时,我得到一个覆盖率报告,但它是空的. gradle执行结束如下:

:androidTest:connectedAndroidTest (Thread[main,5,main]) completed. Took 2 mins 36.951 secs.
:androidTest:createDebugCoverageReport (Thread[main,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,main]) completed. Took 0.215 secs.

BUILD SUCCESSFUL

Total time: 4 mins 53.467 secs

实际上,上面引用的coverage.ec文件为空(长度为0)

在目录build / intermediates / coverage-instrumented-classes /中,我似乎有了已检测的类文件

这是gradle 2.1

我究竟做错了什么?

解决方法

尝试使用Nexus设备(5或5x)生成调试覆盖率报告,它将完美运行.我遇到了与三星设备相同的问题(coverage.ec是空的),但之后我用Nexus 5x运行它,一切正常.
原文链接:https://www.f2er.com/android/310120.html

猜你在找的Android相关文章