I am using make
for building and Robolectric
as a framework for running Android tests. I would like to calculate coverage of my app. For instrumentation tests I used to use emmalib
. What is the best way for me to set up coverage calculation in this case? I can't migrate to gradle or maven.

- 40,948
- 31
- 128
- 181
-
Does this help?: http://stackoverflow.com/questions/13466482/generating-android-code-coverage-though-changes-in-build-xml-and-ant-properties – Vrashabh Irde Jan 27 '15 at 11:47
-
How about using RoboElectric + Cobertura/EclEmma for code coverage? – Vrashabh Irde Jan 27 '15 at 11:52
-
Slartibartfast: We don't use ant. Do you have some tutorial on how to integrate Robo and Cobertura/EclEmma? I will be trying to use JaCoCo today. – gruszczy Jan 27 '15 at 16:18
-
Well most of the tutorials I have come across use ant unfortunately, and I dont think it would be a bad idea for you to use ant. But JaCoCo you could take a look at here: https://intellectualcramps.wordpress.com/2013/08/18/code-coverage-of-robolectric-tests-using-jacoco/ – Vrashabh Irde Jan 28 '15 at 10:07
3 Answers
Are you bound to Emma? How about using RoboElectric + Cobertura code coverage? (I think you could just use a CLI for the above combination)
So options
1.) RoboElectric + Cobertura - CLI alone probably for someone not on ANT
2.) JaCoCo might have some useful options
3.) Pure Android Testing + Emma/EclEmma
Useful Link trails to follow
Generating android code coverage though changes in build.xml and ant.properties
https://intellectualcramps.wordpress.com/2013/08/18/code-coverage-of-robolectric-tests-using-jacoco/
https://bitbucket.org/ravidsrk/androidstarter
EDIT:
Well most of the tutorials I have come across use ant unfortunately, and I don't think it would be a bad idea for you to move to a recommended build system like Gradle so it opens up a lot options. But for JaCoCo you could take a look at here: https://intellectualcramps.wordpress.com/2013/08/18/code-coverage-of-robolectric-tests-using-jacoco/
UPDATE:
Moved this from comments to the answer section for information to anyone wanting to see this and because this is a bounty question

- 1
- 1

- 14,129
- 6
- 51
- 103
One solution would be to use Cobertura to generate code coverage, which can be integrated in eclipse and also run by an ant build script.
A template project of such an integration can be found here: https://github.com/adgllorente/android-cobertura-boilerplate
Note that all of the magic happens in the build.xml of the Test project. Theses tasks should probably be generalised to a custom_rules.xml
file so you can still use android
to update your projects.
Finally, for Gradle you have many different options:
- http://raptordigital.blogspot.nl/2014/08/code-coverage-reports-using-robolectric.html
- http://chrisjenx.com/gradle-robolectric-jacoco-dagger/
- https://stackoverflow.com/a/25037742/2771851
Note that you can always use Gradle as a secondary build system just to generate the coverage reports. (but a second build system will introduce a lot of overhead)

- 1
- 1

- 3,436
- 17
- 24
-
I don't use gradle, or maven, or ant. My build is purely Make based (check out AOSP code base). I will take a look at cobertura, which seems to allow working from cmd line without anything else. – gruszczy Jan 28 '15 at 16:38
jacoco sometimes does not work with Robelectric and powermock runner you can use clover an atlassian tools it is now open source tool.

- 965
- 7
- 10