艾玛报告覆盖率为0% [英] Emma reports 0% coverage

查看:335
本文介绍了艾玛报告覆盖率为0%的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要运行单元测试时,得到code覆盖。
我使用标准Android的build.xml为测试运行蚂蚁报道

I want to get code coverage when running unit tests. I run ant coverage using standard android build.xml for tests.

测试运行良好。从蚂蚁覆盖的最后一个字符串

Tests run: 59,  Failures: 1,  Errors: 4

Generated code coverage data to /data/data/my.package/files/coverage.ec

但coverage.ec文件只有37字节长,几乎是空的。

But the coverage.ec file is only 37 bytes long and is almost empty.

在其上运行艾玛报告告诉

Running emma report on it tells

no collected coverage data found in any of the data files [all reports will be empty]

和生成它的每场美丽的报告与零。

and generates beautiful report with ZEROES in every field of it.

我想这应该艾玛产生更大的coverage.ec。

I suppose that emma should generate a bigger coverage.ec.

我在做什么错了?

--- ---更新

做了一些深挖。看来,大多数的事情都很好,除了覆盖面的结果产生。

Did some deep digging. It seems that most of things are well except coverage result generation.

1)汇编的一切话说

[javac] /blabla/android-sdk-linux_x86/tools/ant/main_rules.xml:384: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 88 source files to /blabla/project/tests/instrumented/classes
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.

2)做<指令输入> 模式=覆盖的项目,是在测试。路径是确定的。

2) It is doing <instr> with mode="overwrite" for the project that is under test. The path is ok.

-emma仪器:
     [回应]从班插入检测/布拉布拉/项目/测试/仪表/班...

-emma-instrument: [echo] Instrumenting classes from /blabla/project/tests/instrumented/classes...

其结果是,有一个与元数据的* .EM文件98类。

As a result, there is a *.em file with metadata for 98 classes.

3)一些标准的Andr​​oid转换DEX,包未对齐,对齐拉链。结果是/blabla/project/tests/instrumented/project-debug.apk。

3) Some standard android conversion to dex, package to unaligned, zip align. Result is /blabla/project/tests/instrumented/project-debug.apk.

4)安装此项目debug.apk到仿真器。

4) Installing this project-debug.apk onto emulator.

5)编译测试项目。
    编译:
    [javac的] /blabla/android-sdk/android-sdk-linux_x86/tool​​s/ant/main_rules.xml:384:警告:​​includeantruntime没有设置,默认为build.sysclasspath =最后;设置为false可重复的构建
    [javac的] 110编译源文件/布拉布拉/项目/测试/斌/班

5) Compiling the tests project. compile: [javac] /blabla/android-sdk/android-sdk-linux_x86/tools/ant/main_rules.xml:384: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 110 source files to /blabla/project/tests/bin/classes

源文件包含所有的previous文件以及测试(110 = 88 +测试),在build.properties(多source.dir用;分隔)称

Source files include all the previous files plus tests (110 = 88 + tests), as stated in build.properties (multiple source.dir separated by ";").

6)资源,地塞米松,签约,拉链对齐......结果是projectTest-debug.apk

6) Resources, Dex, signing, zip align... Result is projectTest-debug.apk

7)安装projectTest-debug.apk到仿真器。

7) Installing projectTest-debug.apk onto emulator.

8)通过运行测试,上午在哪里的报道中指定。它告诉

8) Running tests through am where "coverage on" specified. It tells that

[exec] Generated code coverage data to /data/data/blabla.project/files/coverage.ec

9)该coverage.ec包含任何相关数据。它是37个字节长。它的报告告诉

9) This coverage.ec contains no relevant data. It is 37 bytes long. Report on it tells that

processing input file [/home/ubuntu/projects/ppf2/workspace/PPF2/tests/coverage.ec] ...
loaded 0 coverage data entries
...
no collected coverage data found in any of the data files [all reports will be empty]

似乎一切都对我好,除了最后一步。

Everything seems good for me except the last step.

推荐答案

最后,许多小时的奋战后,问题解决了。
解决方案是非常简单和不可预料的。

Finally, after many hours of fighting, question resolved. Resolution is very simple and unexpectable.

在测试项目中我有这样的事情的build.properties:

In build.properties of the TEST project I had something like:

tested.project.dir=..
env.WORKSPACE= /bla/bla
source.dir=${env.WORKSPACE}/first/src;${env.WORKSPACE}/second/src;${env.WORKSPACE}/andsoon/src;

但是!我不应该指定source.dir在这里!指定 tested.project.dir 就足以成功编译测试项目。

But! I should NOT specify source.dir here! Specifying tested.project.dir is enough to compile test project successfully.

此外,如果我在这样的测试项目指定source.dir - 测试运行良好,但艾玛报告零覆盖,就像在质询时所

Moreover, if I specify source.dir in TEST project like this - tests run well but emma reports zero coverage, just as stated in question.

这篇关于艾玛报告覆盖率为0%的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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