Android: Coverage report for unit tests

You want to have a nice report how much you cover with your Android unit tests? Here a quick walkthrough how to get such a report (see screenshots of report below).

In this example I expect that your test project is in a folder "tests" in your project folder which gets tested.

  1. Create a build.xml for your project (if it does not yet exist)
    android update project --path .```
  2. Create the build.xml for the test project (that will allow us to do the coverage)
    android update test-project -m <full path to main project> -p tests/

Somehow "." does not work and you have to use the full path like “/home/pboos/develop/workspace/project”

  1. Run coverage
    ant coverage```

This will print out the path to the html file where you can see a nice report. Should be in "tests/coverage/coverage.html".


If you have libraries that you use and you get an error. Make sure you put them into a “libs” directory. ant automatically adds the libraries in “libs” to the build path.

Example for coverage report:


If you get an error, that emma.jar (or android) is not in your classpath, you might have forgotten to add the tools directory to your classpath. Follow the instructions below "How to update your PATH" on As well make sure that you have updated the Android SDK Tools (I used revision 11, when I wrote this). How to do this is here:

Subscribe to pboos

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.