If you want to keep track of your test coverage and/or give others insight of the test coverage you can use Coveralls.io. Assuming you have already set up Cobertura, it is quite easy to get Coveralls integrated. There is an existing Gradle plugin to convert and send Cobertura reports to Coveralls. Have a look at “Robolectric and Cobertura with Gradle“, if you want to know how to set up Robolectric and Cobertura.
First add a dependency to “org.kt3k.gradle.plugin:coveralls-gradle-plugin:0.3.0”.
Apply the “coveralls” plugin.
After that make sure that the cobertura plugin generates an XML report as well. In the Cobertura configuration, add the following:
- coverageFormats = ["html", "xml"]
If you’re not running on Travis (pro) you may need to add a service name by specifying “service” in the coveralls plugin configuration.
Add a “COVERALLS_REPO_TOKEN” environment variable containing your coveralls token.
Now that everything is set up, all you need to do is run the below to send a coverage report to Coveralls.
- gradle coveralls
If you want to look into the Gradle Coveralls plugin in more detail, have a look at the coveralls-gradle-plugin project page.