code覆盖率为Android(葫芦 - 机器人BDD) [英] Code coverage for Android (calabash-android BDD)

查看:409
本文介绍了code覆盖率为Android(葫芦 - 机器人BDD)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试我使用葫芦,机器人提供它自己的测试项目的Andr​​oid应用,与重命名它的包装,以反映被测应用程序,然后脚本使用InstrumentationTestRunner子类:

I'm testing my android application using calabash-android which provides it's own "test project", with a script that renames it's package to reflect the app under test, and then uses an InstrumentationTestRunner subclass:

adb shell am instrument -w -e class sh.calaba.instrumentationbackend.InstrumentationBackend #{ENV['TEST_PACKAGE_NAME']}/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner

我会接受任何的答案,让我产生code覆盖类似艾玛或为的Cobertura一个Android应用程序报告,用收集到的数据,而在葫芦 - 机器人进行测试。

I'll accept any answer that allows me to generate a code coverage report similar to Emma or Cobertura for an Android app, with data collected while being tested in calabash-android.

  • 在试图遵循这些说明获得Maven来构建我的项目(​​因为它已经太长时间,因为我用蚂蚁)。 A coverage.em 文件在目标/艾玛
  • 生成
  • 修改葫芦,机器人脚本,加入 -e报道属实
  • 当我运行葫芦-机器人,我终于看到生成的覆盖率数据/data/data/my.project/files/coverage.ec
  • 亚行-e拉/data/data/my.project/files/coverage.ec coverage.ec
  • Attempted to follow these instructions to get Maven to build my project (because it's been too long since I used ant). A coverage.em file is generated in target/emma
  • Modified the calabash-android script, adding "-e coverage true"
  • When I run calabash-android, I eventually see "Generated coverage data to /data/data/my.project/files/coverage.ec"
  • adb -e pull /data/data/my.project/files/coverage.ec coverage.ec

......所以现在我应该能够运行:

...so now I should be able to run:

  • java命令$ ANDROID_HOME / tools / lib目录/ emma.jar艾玛报告-r HTML -in目标/艾玛/ coverage.em,coverage.ec

,但的我得到一个错误:

EMMA: processing input files...
java.io.UTFDataFormatException: malformed input around byte 107

......所以,我认为有href="https://github.com/calabash/calabash-android" rel="nofollow">安卓Maven插件有点毛病 coverage.em 文件。我跑了 Android的更新项目-p。蚂蚁艾玛蚂蚁艾玛调试,但我找不到任何地方coverage.em ...

...So I assume that there's something wrong with the android maven plugin, and I'm trying to figure out how to generate the coverage.em file. I've ran "android update project -p ." and "ant emma" and "ant emma debug", but I can't find coverage.em anywhere...

...生成的build.xml文件似乎暗示,当你运行ant艾玛测试时,才生成的coverage.em文件的生成,但我不认为这是去上班,因为测试程序由蠡 - 机器人控制的。

...The generated build.xml file seems to imply that the generation of the coverage.em file is only generated when you run "ant emma test", but I don't think that's going to work because the test app is controlled by calabash-android.

  • 在谷歌搜索各种形式的Cobertura机器人,但它似乎并没有因为如果任何人有任何运气。
  • 在试图配置的Cobertura轮廓在我的Maven POM文件仪器类,但(在Maven中3)我得到
    • 有关Log4j和蚂蚁有InnerClasses警告的整个堆属性,我应该从源代码重新编译
    • 在该com.jayway.maven.plugins.android.generation2一个错误:Android的Maven的插件:3.3.0:DEXAndroid为040-001:无法执行:命令= / bin / sh的-C-CD /路径/到/ myproject的&放大器;&安培; Java的罐子$ ANDOID_HOME /平台-tools / lib目录/ dx.jar --dex ...
    • Googled various forms of "cobertura android", but it doesn't seem as if anyone has had any luck.
    • Attempted to configure a cobertura profile in my Maven pom file to instrument the classes, but (in Maven 3) I get
      • a whole heap of warnings about log4j and ant having "InnerClasses" attributes and that I should recompile them from source
      • an error that com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.3.0:dex "ANDROID-040-001: Could not execute: Command = /bin/sh -c -cd /path/to/myproject && java -jar $ANDOID_HOME/platform-tools/lib/dx.jar --dex ..."
      EXCEPTION FROM SIMULATION:
      local variable type mismatch: attempt to set or access a value of type 
      java.lang.Class using a local variable of type java.lang.reflect.Type[].  
      This is symptomatic of .class transformation tools that ignore local variable information.
      

      ...这可能是为什么没有人能够得到的Cobertura工作在Android?

      ... this is probably why nobody's been able to get cobertura working on Android?

      推荐答案

      问题是, Maven的Andr​​oid的插件使用艾玛2.1.5320版本,而Android的工具使用2.0.5312版本。由于这里讨论,这两个版本是不兼容的。

      The problem is that maven-android-plugin uses version 2.1.5320 of emma, whereas the Android tools use version 2.0.5312. As discussed here, those two versions are incompatible.

      解决办法是只使用一个版本在这两个工具。我已经能够得到它通过克隆 Maven的Andr​​oid的插件回购,设置艾玛依赖版本回到2.0.5312工作,并安装到我的地方存储库。请确保您在测试项目中的艾玛依赖也是正确的,那么你应该能够产生一个覆盖面。

      The fix is to only use a single version across the two tools. I've been able to get it to work by cloning the maven-android-plugin repo, setting the emma dependency version back to 2.0.5312, and installing it to my local repository. Make sure the emma dependency in your under-test project is also correct, and then you should be able to generate a coverage.

      另一种方法是,以确保所有的工具都将使用最新版本。我没有测试它,但它可能工作,如果你从行家做报告生成的版本是一样的话。你也可以下载艾玛的最新版本,并生成使用jar从包中报告。

      The alternative is to make sure all of the tools are using the newest version. I haven't tested it, but it might work if you do the report generation from maven is the version will be the same then. You could also download the newest version of emma and generate the report using the jar from that package.

      这篇关于code覆盖率为Android(葫芦 - 机器人BDD)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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