我正在使用测试我的 Android 应用程序葫芦安卓 https://github.com/calabash/calabash-android它提供了它自己的“测试项目”,以及一个重命名其包以反映测试下的应用程序的脚本,然后使用 InstrumentationTestRunner 子类:
adb shell am instrument -w -e class sh.calaba.instrumentationbackend.InstrumentationBackend #{ENV['TEST_PACKAGE_NAME']}/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner
我会接受任何允许我为 Android 应用程序生成类似于 Emma 或 Cobertura 的代码覆盖率报告的答案,并在 calabash-android 中测试时收集数据。
为了让艾玛工作,我......
- 尝试跟随这些说明 http://code.google.com/p/maven-android-plugin/wiki/EmmaMaven让 Maven 来构建我的项目(因为我已经很久没有使用 ant 了)。 A
coverage.em
文件生成于target/emma
- 修改了 calabash-android 脚本,添加“
-e coverage true
"
- 当我运行 calabash-android 时,我最终看到“生成的覆盖数据到 /data/data/my.project/files/coverage.ec”
adb -e pull /data/data/my.project/files/coverage.ec coverage.ec
...所以现在我应该能够运行:
java -cp $ANDROID_HOME/tools/lib/emma.jar emma report -r html -in target/emma/coverage.em,coverage.ec
but我收到错误:
EMMA: processing input files...
java.io.UTFDataFormatException: malformed input around byte 107
...所以我认为有问题Android Maven 插件 https://github.com/calabash/calabash-android,我正在尝试找出如何生成coverage.em
文件。我已经跑了”android update project -p .
" and "ant emma
" and "ant emma debug
", but 我在任何地方都找不到coverage.em...
...生成的 build.xml 文件似乎意味着只有在运行“ant emma test”时才会生成coverage.em 文件,但我认为这不会起作用,因为测试应用程序是由葫芦-android。
为了让 Cobertura 工作,我......
- 谷歌搜索了各种形式的“cobertura android”,但似乎没有人有任何运气。
- Attempted to configure a cobertura profile in my Maven pom file to instrument the classes, but (in Maven 3) I get
- 关于 log4j 和 ant 具有“InnerClasses”属性的一大堆警告,我应该从源代码重新编译它们
- com.jayway.maven.plugins.android. Generation2:android-maven-plugin:3.3.0:dex “ANDROID-040-001: 无法执行: Command = /bin/sh -c -cd /path/ 的错误到/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 上运行的原因?