4

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?

nicobatu
  • 1,377
  • 3
  • 15
  • 34
  • did u get it to work? I am still getting only the App not the library. I added the "tested.project.lib.source.path" in ant.properties and made it point to my libary/src folder. – Akshat Nov 11 '12 at 19:02

2 Answers2

3

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.

Community
  • 1
  • 1
Grantland Chew
  • 2,620
  • 26
  • 26
  • Hey, I just checked out that tutorial, and I have a question. That path under: "# This can be a semicolon delimited list of directories tested.android.library.source.dir=../library/src;etc", is that the location of my android source? What does the author mean by "/library/src/etc"? – NioShobu Aug 21 '12 at 18:56
  • @NioShobu That is a semi-colon delimited list of your library project source directories. – Grantland Chew Aug 25 '12 at 07:17
0

The Emma documentation mentions instrumenting jars ( http://emma.sourceforge.net/ ) so it seems possible, perhaps you need to play with the configuration settings a bit.

Good luck.

cjstehno
  • 13,468
  • 4
  • 44
  • 56