【问题标题】:Android - Espresso tests code coverage for multi module projectAndroid - Espresso 测试多模块项目的代码覆盖率
【发布时间】:2020-10-29 18:18:40
【问题描述】:

我的项目结构如下:

模块应用

androidTest //Espresso tests covers classes from login and registration
main //Contains UI and business logic
test

模块登录

androidTest //No tests written
main //Contains UI and business logic
test //Only unit tests 

模块注册

androidTest //No tests written
main //Contains UI and business logic
test

问题:我有上面类似的 android 项目结构并且能够生成 jacoco 代码覆盖率报告,它可用于声纳仪表板。我面临的问题是 espresso 测试仅显示模块应用程序的代码覆盖率,而不显示其他模块的代码覆盖率。 Espresso 测试针对注册等用例流程运行,然后登录并从其他两个模块调用类,但其他两个模块的覆盖率始终为 0%。

  • 我想了解 espresso 是如何生成代码覆盖率的,它是否类似于单元测试,其中编写单元测试的包和类相同?
  • 如何从 espresso 测试中编写的代码中逐行查看覆盖率?这些测试涵盖了整个项目 src 中的所有类。
  • 我是否也应该在其他模块中编写 espresso 测试?不确定它是否会显示覆盖范围。
  • 请针对 espresso 代码覆盖率提出任何缺失的配置。

【问题讨论】:

    标签: android sonarqube code-coverage android-espresso android-instrumentation


    【解决方案1】:

    如果 androidTest 中没有针对任何特定模块的测试,Jacoco 和 sonar 将不会显示覆盖率。一旦测试出现在 androidTest 中,它将开始向声纳仪表板显示覆盖数据。

    【讨论】:

      猜你喜欢
      • 2015-01-10
      • 1970-01-01
      • 1970-01-01
      • 2014-10-13
      • 2017-06-24
      • 1970-01-01
      • 2014-10-03
      • 1970-01-01
      • 2012-01-07
      相关资源
      最近更新 更多