Search code examples
androidantcode-coverageemma

Emma code coverage for a lib on Android


I currently have some unit tests for an Android app, which makes calls to a library jar file. I would like to see the code coverage for the jar, but when I run ant emma and look at the coverage.html, it only reports on the coverage of the app project.

Is there a way to specify that I would like to view the coverage for the jar as well?


Solution

  • The ADT r20-preview solves this issue by giving access to the full classpath of tested projects and their Library Projects:

    http://tools.android.com/download/adt-20-preview

    Fixes in Ant:

    • Test projects now have access to the full classpath from the tested projects, including Library Projects and 3rd party jar
    • Applications embedding tests can now be deployed and tested, including with code coverage, like test applications.

    This will give you code coverage reports on your library projects, but you will have to do some modifying of the test target of build.xml to attach the source files too. See Attach Android library project source code to Emma report (ant, emma) for more information on how to incorporate emma test coverage for your library projects for the time being.