Converting Jacoco Test Reports to Cobertura or Clover Format

February 10, 2015

The Jacoco framework is an excellent tool to generate test coverage reports for your Android Gradle project. Sometimes you’ll need your test coverage reports in another format, such as Cobertura or Clover (used by Atlassian tools to track test coverage). We use Atlassian Bamboo to automatically build our projects and perform code tests, so we needed to convert our Android project test coverage reports from Jacoco format to Clover format. This way, we could benefit from Bamboo’s ability to track test coverage per build and over time.

Here’s what a test coverage summary looks like in Atlassian Bamboo:



Converting from Jacoco to Cobertura

Thanks to a simple Python script from this Github repository you can easily convert your Jacoco test coverage reports to Cobertura format.

In your app’s base directory, run these shell commands to create a Cobertura reports directory alongside your Jacoco reports directory and then perform the conversion.

mkdir -p ./app/build/reports/cobertura
python cover2cover.py ./app/build/reports/jacoco/jacocoTestReport/jacocoTestReport.xml src/main/java > ./app/build/reports/cobertura/coverage.xml

Converting from Cobertura to Clover

Converting from Cobertura test coverage format to Clover format is done with the cobertura-clover-transform Python tool.

Run this shell command to use the Python package installer tool pip to install the cobertura-clover-transform tool.

pip install lxml cobertura-clover-transform

In your app’s base directory, run these shell commands to create a Clover reports directory and then perform the conversion from Cobertura to Clover.

mkdir -p ./app/build/reports/clover
python -m cobertura_clover_transform.converter ./app/build/reports/cobertura/coverage.xml > ./app/build/reports/clover/clover.xml
Joseph Kreiser
Joseph Kreiser
Software Developer

Stay in the loop with our latest content!

Select the topics you’re interested to receive our new relevant content in your inbox. Don’t worry, we won’t spam you.

Three principles for creating user-friendly products
Business Design

Three principles for creating user-friendly products

January 25, 2023

Grayson discusses three guiding principles he utilizes when designing user experiences for products.

Read more
Michigan Software Labs breaks ground on new office
Press Release

Michigan Software Labs breaks ground on new office

June 19, 2020

Michigan Software Labs recently broke ground on a new office building in its hometown of Ada. The 16,500-square-foot, three-story building will have office space for the growing software company and support up to 75 team members. The company currently is hiring for developers, UX designers and project managers.

Read more
Chicago Roboto 2020: A Virtual Success
Android

Chicago Roboto 2020: A Virtual Success

January 19, 2021

Looking back on last year’s Chicago Roboto, it was a great opportunity to learn while spending time hanging out with teammates. So, when it was announced that this year’s event was going to be virtual, it was hard not to be disappointed. Then again, with so many great speakers lined up, there was still plenty to look forward to.

Read more
View more articles