What are my alternatives for covering test code on Android?

I know that the Android Ant toolkit comes with built-in Emma coverage code, but Emma reports look more and more dated and cannot be easily integrated into other coverage reports or even sonar, mainly because Emma does not have a detailed format XML reporting. I want to reach

  • code coverage for unit tests (Robolectric-based, already done with Cobertura)
  • code coverage for integration tests (Robotium- / emulator-based, currently run separately with Emma)
  • perfectly merging code coverage results (this IMHO is only possible with Cobertura and requires raw * .ser files from each test run)
  • publication on Sonar (currently only with unit test coverage, Sonar understands only one coverage format as far as I know)

Do I have any alternatives?

edit: This sonar-devel post probably summarizes the current state of support for Android code coverage, as well as sonar support to a large extent, Sigh

+7
source share
3 answers

I clicked on the github repository that contains the same configuration that you mentioned in your question:

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

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

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

A colleague and I mean working on this issue with very similar thinking, like you. We want to improve the integration of various testing technologies that will be available for Android projects, and to report on the work in sonar.

If you want to join our efforts, we will be happy to give you repo rights and start working with you.

Stéphane

- Update

Starting in March 2013, we also offer a single configuration for using the Jacoco online tools for robolectric and standard junit tests and getting results displayed simultaneously in Sonar.

+6
source

You can use the robolectric framework. This will allow you to run JUnit Tests on the Java VM instead of using the Android Junit Tests that run on the Dalvik VM. This will allow you to use any standard coverage tool (EclEmma, ​​CodeCover, Cobertura, etc.). It is easy to configure and works stably (which you cannot say from the Clover tool).

+2
source

Disclaimer: I'm Atlas

Yes. There is an alternative - you can use the Atlassian Clover tool. There is an alpha version of Clover-for-Android available from https://confluence.atlassian.com/display/CLOVER/Clover-for-Android

You wrote that you want to achieve the following:

  • code coverage for unit tests - yes, Clover supports "Run as> Android JUnit Test", as well as "Run as> JUnit Test" - that is, without running the emulator (but the latter will require a slightly different configuration, as described in the Clover Guide for-android)
  • code coverage for integration tests - as stated above, "Run as Android JUnit Test"
  • perfectly merging code coverage results - yes, you can combine code coverage results from several test runs; what else can you even run the application in an emulator or device and perform manual tests (sic!)
  • publication in Sonar - there is Clover Sonar Plugin , however I have not tested it using Clover-for-Android; you will probably have to run tests in Eclipse, the next export XML or HTML report (a button in the Explorer Clover Coverage view) and push these files to the Sonar assembly.
+1
source

All Articles