Code coverage for Android [duplicate]
Asked Answered
D

4

24

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?

Dominic answered 6/6, 2011 at 16:1 Comment(1)
I have it setup outside of eclipse but yeah as for integrating it within the apk building steps in eclipse, I think you might have to use the adt lib that is in the source tree of android :( I haven't found a way to do this. But I don't find interactive coverage through the IDE as helpful as running automated tests with coverage analysis (it's trackable that way). I do that all through ant. If it helps here, #4074181Menticide
P
2

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/

Pergrim answered 20/10, 2012 at 18:49 Comment(0)
N
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.

Nonproductive answered 10/7, 2011 at 15:6 Comment(0)
P
2

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/

Pergrim answered 20/10, 2012 at 18:49 Comment(0)
P
1

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.

Pubis answered 29/6, 2011 at 14:8 Comment(0)
E
1

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

Exclude answered 12/7, 2011 at 3:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.