Android 的代码覆盖率
可能的重复:
Android 测试代码覆盖率,Eclipse
看到没有文档说明如何在 Eclipse 中将 EMMA 用于 Android 应用程序。有没有人设法在 Android 应用程序的 Eclipse 中使用 EMMA?没有检查整个 Android 源代码并进行所有黑客攻击?
Possible Duplicate:
Android test code coverage, Eclipse
Its really frustrating to see there is no documentation for how to use EMMA for Android apps in Eclipse. Has anyone managed to work with EMMA in eclipse for Android apps? Without checking out the whole android source and do all the hackery?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您有
<测试项目的路径>/build.xml
文件,请重命名它。我能够通过从控制台执行以下
命令来生成测试覆盖率报告:
android update test-project -m; -p <测试项目的路径>
+ Enter,cd <测试项目的路径>
+ Enter,>ant emma debug install test
+ Enter,其中
是我的机器上的/opt/android-sdk-linux/tools/
- 安装 android SDK 的文件夹。这生成了
<测试项目的路径>/bin/coverage.html
文件。如果出现“错误的 JAVA_HOME”错误,请执行
gksu gedit /etc/environment
+ Enter,更正JAVA_HOME
,保存文件,注销或重新启动然后再试一次。来源: http://blog.rabidgremlin.com/2010/11/19/android-tips-generating-a-coverage-report-for-your-unit-tests/
If you have
<path to test project>/build.xml
file rename it.I was able to generate test coverage report by executing following from the console:
<path to android tools>android update test-project -m <path to app project> -p <path to test project>
+ Enter,cd <path to test project>
+ Enter,ant emma debug install test
+ Enter,where
<path to android tools>
is/opt/android-sdk-linux/tools/
on my machine - the folder where android SDK is installed.This generated
<path to test project>/bin/coverage.html
file.If you get "wrong JAVA_HOME" error execute
gksu gedit /etc/environment
+ Enter, correctJAVA_HOME
, save the file, log out or reboot and try again.Source: http://blog.rabidgremlin.com/2010/11/19/android-tips-generating-a-coverage-report-for-your-unit-tests/
这并不能直接回答您的问题,但我建议您看一下使用 Robolectric 编写测试: http:// /pivotal.github.com/robolectric/
使用 Robolectric,您可以在 JVM 而不是 Delvik VM 中编写运行测试。这意味着您几乎可以使用任何 JAVA 代码覆盖率工具。您可能需要稍微更改一下代码,以便可以编写 Robolectric,而且您还没有开始破解 Robolectric。对我来说,这只是编写测试的更好方法。
This does not answer your question directly, but I would suggest you to take a look at writing test with Robolectric: http://pivotal.github.com/robolectric/
With Robolectric, you can write your testing running inside JVM instead of Delvik VM. That means you can use almost any code coverage tool for JAVA. You might have to change your code a bit so you can write your Robolectric, and also you have not start hacking Robolectric too. To me, it is just a better way to write test.
不幸的是,我认为 EMMA 不适用于通过 SDK 开发的应用程序。除非自我上次阅读该主题以来情况发生了变化。这些工具专为与操作系统本身一起使用而设计,因此据我所知,无法将其与您的 APK 一起使用。
您可能会发现以下相关帖子很有用 - Android 中的 EMMA 代码覆盖率。
Unfortunately I believe EMMA is not applicable to Apps developed via the SDK. That is unless things have changed since I last read up on the topic. The tools are designed for use with the OS itself and as such there's no way of using it with your APK that I know of.
You may find the following related post useful - EMMA Code Coverage in Android.
我发现几个链接可能会有帮助
http://blog.pboos.ch/2011/06/coverage -fo-android-测试/
你还可以检查
如何在 Android 中使用 EMMA 代码覆盖率
希望它对你有用
i found few links it may be helpful
http://blog.pboos.ch/2011/06/coverage-fo-android-tests/
you can also check
How to use EMMA code coverage in android
hope it works for you