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
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
With that being said it is generally accepted that 80% coverage is a good goal to aim for. Trying to reach a higher coverage might turn out to be costly, while not necessary producing enough benefit. The first time you run your coverage tool you might find that you have a fairly low percentage of coverage.
Android Studio has a built-in feature that allows you to run tests with code coverage. Simply navigate to the src/test/java folder and right click. Then select Run 'Tests in 'java'' with Coverage (awkward use of single quotes theirs not mine).
I have pushed a github repo that contains the same configuration as you mentionned in your question :
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.
You can use the robolectric framework. It will allow you to run JUnit Tests on the Java VM instead of using Android Junit Tests that run on the Dalvik VM. This will allow you to use any standard coverage Tool out there (EclEmma, CodeCover, Cobertura, etc.). It's easy to configure and runs stable (What you can't say from the Clover tool).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With