合并Android单元测试和连接的测试代码覆盖率数据已损坏 [英] Merging Android unit test and connected test code coverage data is broken

查看:169
本文介绍了合并Android单元测试和连接的测试代码覆盖率数据已损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android Gradle插件的版本2.3.3能够提供合并的单元测试和连接的测试代码覆盖率数据.在3.0.0版中,由于每种测试类型都使用JaCoCo的不同且不兼容的版本,因此此功能已被破坏.拉斐尔·托莱多(Rafael Toledo)提供了 Github存储库,该代码说明了几个分支中的工作代码和损坏的代码. 回购文档提供了该问题的读者文摘"描述.在这一点上,我确信Gradle插件团队拥有该问题,并将在短期内提交一个错误.我的问题是:

Version 2.3.3 of the Android Gradle Plugin was able to provide merged unit test and connected test code coverage data. In version 3.0.0, this capability is broken because each of the test types use a different and incompatible version of JaCoCo. Rafael Toledo provided a Medium blog post showing how to make this work with 2.3.3. I have provided a Github repo that illustrates the working code and the broken code in a few branches. The repo documentation provides a Readers Digest description of the problem. At this point I am convinced the Gradle Plugin team owns the issue and will file a bug shortly. My questions are:

1)有人可以建议可行的解决方法吗? (Carmen Alvarez提出了一个建议的修复程序,该修复程序已发布到Medium博客中,但我对此并不感到高兴.)

1) Can anyone suggest a viable workaround? (there is a suggested fix by Carmen Alvarez posted to the Medium blog post but I get no joy from it.)

2)有人可以向我指出有关如何破解和构建Gradle Android插件以测试潜在修补程序的说明吗? (我在 http://tools.android.com/build/gradleplugin)

2) Can someone point me to instructions on how to hack and build the Gradle Android Plugin to test out a potential fix? (I found the answer to this one at http://tools.android.com/build/gradleplugin )

推荐答案

根据

要指定要使用的JaCoCo的版本,现在需要将其作为buildscript依赖项包括在项目级别的build.gradle文件中,如下所示:

To specify the version of JaCoCo you want to use, you now need to include it as a buildscript dependency in your project-level build.gradle file, as follows:

buildscript {
      dependencies {
        classpath "org.jacoco:org.jacoco.core:<jacoco-version>"
        ...
    }
}

以前,Android插件具有

Previously Android Plugin had

android {
    jacoco {
        version = "<jacoco-version>"
    }
}

贡献任务的JaCoCo插件文档类型为JacocoReport:

JaCoCo插件添加了一个名为Jacoco的项目扩展名,类型为JacocoPluginExtension,可在您的构建中配置JaCoCo使用的默认值.

The JaCoCo plugin adds a project extension named jacoco of type JacocoPluginExtension, which allows configuring defaults for JaCoCo usage in your build.

jacoco {
    toolVersion = "<jacoco-version>"
}

因此,这是对 https://github.com/pajato/acc 的修改允许对齐版本,以便成功执行./gradlew clean jacocoTestReport:

And so here is modification for your https://github.com/pajato/acc that allows to align versions so that execution of ./gradlew clean jacocoTestReport succeeds:

buildscript {
    dependencies {
        classpath "org.jacoco:org.jacoco.core:0.7.9"
    }
}

allprojects {
    apply plugin: "jacoco"
    jacoco {
        toolVersion = "0.7.9"
    }
}

这篇关于合并Android单元测试和连接的测试代码覆盖率数据已损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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