What are my alternatives for test code coverage on Android?

Thomas Keller picture Thomas Keller · Sep 20, 2012 · Viewed 7.4k times · Source

I know Android's Ant tooling comes with built-in Emma code coverage, but Emma's reports look more and more dated and cannot be easily integrated into other coverage reports or even Sonar, basically because Emma lacks a detailed XML reporting format. What I want to achieve is

  • code coverage for unit tests (Robolectric-based, already done with Cobertura)
  • code coverage for integration tests (Robotium-/emulator-based, currently done separately with Emma)
  • ideally merging code coverage results (this is IMHO only possible with Cobertura and requires the raw *.ser files from every test execution)
  • publishing to Sonar (currently only done with the unit test coverage, Sonar understands only one coverage format to my knowledge)

Do I have any alternatives?

edit: This post on sonar-devel probably sums up the current state of Android code coverage support as well as Sonar support pretty much. sigh

Answer

Snicolas picture Snicolas · Jan 13, 2013

I have pushed a github repo that contains the same configuration as you mentionned in your question :

  • standard android testing + emma code coverage
  • robolectric + cobertura code coverage (btw thx, I thought cobertura was not compatible with robolectric)

and their inclusion in sonar. Only one at a time, but still the configuration is an interesting base to work on.

https://github.com/stephanenicolas/Quality-Tools-for-Android

A colleague and I have in mind to work on this issue with a very similar mindset as you do. We want to get better integration of different testing technologies to be available for Android projects and reporting to work in sonar as well.

If you want to join our effort, we would be happy to give you the rights to the repo and start working with you.

Stéphane

-- Update

Since march 2013, we also propose a unified configuration to use Jacoco offline instrumentation for both robolectric and standard junit tests and get results displayed simultanously in Sonar.