Code coverage for Android [duplicate]

人走茶凉 提交于 2019-12-03 05:41:36

问题


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?


回答1:


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, correct JAVA_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/




回答2:


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.




回答3:


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.




回答4:


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



来源:https://stackoverflow.com/questions/6254771/code-coverage-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!