Search code examples
androideclipseemma

Code coverage for 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?


Solution

  • 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/