JaCoCo的覆盖率显示为0%,即使所有测试都通过了 [英] JaCoCo shows 0% coverage, even all tests had passed

查看:4240
本文介绍了JaCoCo的覆盖率显示为0%,即使所有测试都通过了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我在androidTest目录下写了一些测试用例.
  2. 我正在使用androidx(testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner")
  3. 添加了依赖项:

  1. I have written some test cases under androidTest directory.
  2. I am using androidx (testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner")
  3. added dependencies:

androidTestImplementation 'androidx.test:runner:1.1.0'

androidTestImplementation 'androidx.test:rules:1.1.0'

也将JaCoCo添加为依赖项.

added JaCoCo as dependency, as well.

我猜测是由于此错误导致的:

I am guessing that is due to this error:

V/InstrumentationResultParser:错误:无法生成Emma/JaCoCo承保范围. V/InstrumentationResultParser:INSTRUMENTATION_CODE:-1

V/InstrumentationResultParser: Error: Failed to generate Emma/JaCoCo coverage. V/InstrumentationResultParser: INSTRUMENTATION_CODE: -1

推荐答案

很有可能不需要androidx.test.runner.AndroidJUnitRunner的自定义版本.

A custom version of the androidx.test.runner.AndroidJUnitRunner is most likely not required.

但这是您定义为debugTree的路径:

But this path here, which you've defined as the debugTree:

"${project.buildDir}/intermediates/classes/debug"

同时可能是类似的东西:

Might meanwhile be something alike:

"${project.buildDir}/intermediates/javac/debug/compileDebugJavaWithJavac/classes"

例如:

build/intermediates/javac/debug/compileDebugJavaWithJavac/classes
build/intermediates/javac/release/compileReleaseJavaWithJavac/classes

如果找不到*.class文件,则测试覆盖率将报告为0%.

If it cannot find the *.class files, the test-coverage will be reported as 0%.

只需浏览build目录以查看实际路径是什么.

Just browse the build directory to see what the actual path is.

这篇关于JaCoCo的覆盖率显示为0%,即使所有测试都通过了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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