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?
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.
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
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/
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.