android jacoco覆盖率显示0%,但是有95%的测试覆盖了代码 [英] android jacoco coverage shows 0% with gradle however there are 95% tests covering code

查看:1194
本文介绍了android jacoco覆盖率显示0%,但是有95%的测试覆盖了代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让jacoco为我的android测试项目创建一个代码覆盖率报告。



Gradle版本 classpath'com.android。 tools.build:gradle:2.0.0'



在build.gradle中有以下内容:

  apply plugin:'com.android.application'
apply plugin:'jacoco'

jacoco {
toolVersion =0.7.1.201405082137
}

android {
buildTypes {
release {
}
debug {
testCoverageEnabled true
}
}
}

它显示如下图



我试着用JDK7& 8但结果相同。也尝试转换到JaCoCo的最新版本,但结果仍然相同。



报告显示为0%覆盖率的任何想法?当运行Gradle任务时,它会在androidTest文件夹中成功运行我的测试。





唯一改变的是 compileSdkVersion 23 25 buildToolsVersion > 23.0.1 到 25.0.2 ,因为这是我拥有的版本。 / p>

I'm trying to get jacoco create a code coverage report for my android test project.

Gradle version classpath 'com.android.tools.build:gradle:2.0.0'

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
        }
    }
}

It shows report as below image

There is almost 95% of the code coverage (When I ran the same report in 2015 it showed the report as 95%). Nothing much changed in the code and the test folders ever since then. So ideally it should show coverage as something like this

I tried running report with both JDK7 & 8 but same result. Also tried changing to latest versions of JaCoCo, but still same result.

Any ideas why the report is shown as 0% coverage? While running the Gradle task it runs my tests in androidTest folder successfully though.

Facing same issue as mentioned in this question - This question is unanswered yet

解决方案

Generation of coverage for your project using command

./gradlew clean createDebugCoverageReport

works just fine:

The only thing that I changed - is compileSdkVersion from 23 to 25 and buildToolsVersion from 23.0.1 to 25.0.2, because this is the versions that I have.

这篇关于android jacoco覆盖率显示0%,但是有95%的测试覆盖了代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆