How to calculate coverage when using Robolectric

I use make to build and Robolectric as the basis for running tests on Android. I would like to calculate the coverage of my application. For control tests, I used emmalib . What is the best way to adjust coverage calculation in this case? I can not switch to gradle or maven.

+6
source share
3 answers

Are you associated with Emma? How about using RoboElectric + Cobertura ? (I think you could use the CLI for the above combination)

So, the parameters

1.) RoboElectric + Cobertura - only CLI, probably for someone not on ANT

2.) JaCoCo may have some useful options.

3.) Pure Android + Emma / EclEmma testing

Useful Tracking Links

Android code coverage generation with changes to build.xml and ant.properties

Android Gradle Code Coverage

https://intellectualcramps.wordpress.com/2013/08/18/code-coverage-of-robolectric-tests-using-jacoco/

https://bitbucket.org/ravidsrk/androidstarter

EDIT:

In most of the manuals I came across, using ANT is unfortunately, and I don’t think it would be a bad idea to move to the recommended build system, for example Gradle, so that it opens up many options, But for JaCoCo you can see here: https: //intellectualcramps.wordpress.com/2013/08/18/code-coverage-of-robolectric-tests-using-jacoco/

UPDATE:

This has been moved from the comments to the response section for information to everyone who wants to see it, and because it is a question of generosity

+4
source

One solution would be to use Cobertura to create code coverage that can be integrated into eclipse, and also run using the ant build script.

A draft template for such integration can be found here: https://github.com/adgllorente/android-cobertura-boilerplate

Note that all the magic happens in the build.xml of the test project. These tasks should probably be generalized to the custom_rules.xml file, so you can use android to update your projects.

Finally, for Gradle, you have many different options:

Please note that you can always use Gradle as an additional build system to generate coverage reports. (but the second build system will introduce a lot of overhead)

+1
source

jacoco sometimes does not work with Robelectric and powermock runner, you can use clover for atlassian tools, now it is an open source tool.

0
source

Source: https://habr.com/ru/post/981086/


All Articles