艾玛不产生coverage.ec [英] Emma does not generate coverage.ec

查看:490
本文介绍了艾玛不产生coverage.ec的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的设置Emma和它曾经为我工作。然后我们有源$ C ​​$ C的变化,现在,它不会产生 coverage.ec 可言。它产生 coverage.em 。 邻近测试结束,它有错误消息:

I setup Emma and it used to work for me. Then we had source code changes and now it doesn't generate coverage.ec at all. It does generate coverage.em. Near the end of testing, it has error messages:

[exec] INSTRUMENTATION_CODE: 0
[echo] Downloading coverage file into project directory...
[exec] remote object '/sdcard/coverage.ec' does not exist

BUILD FAILED
/var/lib/jenkins/android-sdk-linux_x86/tools/ant/build.xml:1056: exec returned: 1.

build.xml中的1056线是

Line 1056 of build.xml is

"{adb}" failonerror="true".

我看到,我确实有 coverage.em 的桌面,这意味着我的code的仪器上。

I see that I do have coverage.em on the desktop, which means my code are instrumented.

我下的\测试中使用的命令是

the command I use under the \test is

ant emma debug install test

这之前,为我工作。运行code覆盖老是死机对我来说,平时的单元测试接近尾声,但它会永远给我一些报道。现在它崩溃了,并不会产生 coverage.em

This worked for me before. Running code coverage always crashes for me, usually near the end of the unit test, but it'd always get me some coverage. Now it crashes out and doesn't produce coverage.em.

我也试图访问 / SD卡/ ,这是完全访问和写入。

I also tried to access /sdcard/ and it's perfectly accessible and writable.

这阻止了我好几天,任何输入将是非常美联社preciated。我也是新来的所有这个Android,蚂蚁和艾玛,十分感谢!

This has blocked me for days, any input would be much appreciated. I am also new to all this Android, Ant and Emma, so thanks!!

更新: 我只是清理环境和运行命令again.Now coverage.em不再要么产生。它告诉我的来源$ C ​​$ c的好工具。但我上面所用的命令应仪器项目,其测试项目,安装并启动测试。我没有改变艾玛高清build.xml中,除了改变coverage.ec位置/sdcard/coverage.ec。这是因为默认情况下它进入/数据/数据​​,和我没有权限访问该手机上的数据/数据​​

Update: I just cleaned up the environment and ran the command again.Now coverage.em is no longer generated either. Which tells me the source code are not instrumented. But the command I used above should instrument project, its test project, install and start test. I didn't change emma def in build.xml except to change the coverage.ec location to /sdcard/coverage.ec. This is because by default it goes to /data/data, and I don't have permission to access data/data on this phone

我使用的R15的Andr​​oid SDK,以及默认的build.xml。我只是改变了路径coverage.ec到/sdcard/coverage.ec。要运行仪表

I am using r15 of Android SDK, and the default build.xml. I only changed the path to coverage.ec to /sdcard/coverage.ec. To run instrumentation

 Go to main_project
 $andriod update project -p .
 Go to main_prject\test
 $android update project -m ../ -p .
 To start code code
 $ant emma debug install test

据生成main_project-instrumented.apk和test_project-debug.apk。两者都安装了,我可以看到它执行的测试。

It generated main_project-instrumented.apk and test_project-debug.apk. Both are installed and I can see it executes testing.

推荐答案

您必须做一个测试项目与Android的命令行工具第一。

You have to make a test project with the android command line tools first.

假设你的项目存储在 D:\ AndroidProject 和对Android的API 8级。首先你的编程,你使用这个命令来创建项目:

Assuming your project is stored in D:\AndroidProject and your programming against android API level 8. First you use this command to create the project:

android update project --path ./ --name blabla~ --target android-8 --subprojects 

然后创建一个文件夹的测试项目,然后导航到该文件夹​​:

Then create an folder for the test project and navigate into that folder:

mkdir Android_test
cd Android_test

然后用下面的命令创建了Android测试项目

Then create the android test project with the below command

 android create test-project --main ../AndroidProject --path ./

蚂蚁​​建设与艾玛覆盖报告(带根)

执行以下命令(从詹金斯选择和建立步骤)来获取与艾玛做了构建报告:

Ant building with emma coverage report (with root)

Execute this command (from jenkins select and build step) to get a build done with emma reporting:

ant emma debug install test

注意:对于这个工作,你必须扎根连接设备或模拟器,然后执行ant命令

Caution : For this to work you have to connect rooted device or emulator, then execute ant command!

如果你不希望根设备的替代的解决方案是改变这些覆盖报告的位置。为此,应该修改build.xml文件。

If you don't want to root your device an alternative solution is to alter the location of these coverage reports. For this you should modify the build.xml file.

(你应该使用Google有关的更多信息,这里简要介绍)

打开build.xml文件 - >查找位置,其中 coverage.ec 文件存储。在大多数情况下,这将被存储在 /data/data/com.example.Android/coverage.ec

Open the build.xml -> find the location where the coverage.ec file is stored. In most cases this will be stored in /data/data/com.example.Android/coverage.ec

这里的问题是, /数据/数据​​/ ~~~ 路径是受保护的(因此需要根)。

The problem here is that the /data/data/~~~ path is protected (hence the required root).

反正〜你可以得到一个 coverage.html 在您的测试项目文件夹中的文件/ bin中。接下来的步骤说明如何改变这种保存在这个文件中的 / SD卡,而不是!

anyway~ you can get a coverage.html file in your test project folder/bin. The next steps explain how to change this to save this file on the /sdcardinstead!

您可以打开你的的build.xml 文件,并在最后一行〜你可以找到的命令进口~~~的build.xml 这意味着你的build.xml文件将导入anoother build.xml文件。

You can open your build.xml file and at the last line ~ you can find the command import ~~~ build.xml which means that your build.xml file will import anoother build.xml file.

另外build.xml文件是Android SDK的一部分,位于 $ {Android的SDK} /tool​​s/ant/build.xml

The other build.xml file is part of the android SDK and is located at ${Android-sdk}/tools/ant/build.xml.

我们无法改变这个文件(不陷入麻烦),所以不是完整的文件复制到其他位置,或直接到你的项目build.xml文件。

We can't change this file (without getting into trouble) so instead copy the complete file to an alternative location or directly into your projects build.xml file.

不要忘记调整或改变import语句无论你选择做你的build.xml文件。

这是你所需要的新的build.xml文件,以更改:

This is what you need to change in that new build.xml file:

  • 擦除进口= ~~的build.xml
  • 在擦除这是第一行 XML = ejkwjkw的ΔEJW,项目=android_rule ~~布拉布拉)
  • 和最后一行 /项目
  • 更新地址 /sdcard/coverage.ec
  • Erase the import= ~~build.xml
  • Erase the first line which is xml=ejkwjkw?e jw ""project = "android_rule" ~~ ~blabla)
  • and last line /project
  • update address to /sdcard/coverage.ec

然后,你可以得到coverage.ec文件〜

Then, you can get coverage.ec file~

这篇关于艾玛不产生coverage.ec的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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