Development

Converting JaCoCo test reports to Cobertura or Clover format

February 10, 2015
Converting JaCoCo test reports to Cobertura or Clover format

The Java Code Coverage (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

Looking for more like this?

Sign up for our monthly newsletter to receive helpful articles, case studies, and stories from our team.

MichiganLabs’ approach to software delivery: 3 ways delivery leads provide value
Process Team

MichiganLabs’ approach to software delivery: 3 ways delivery leads provide value

February 12, 2024

Delivery leads ensure the successful execution of custom software development. They build great teams, provide excellent service to clients, and help MichiganLabs grow. Learn what you can expect when working with us!

Read more
What to know about the cost of custom app development
Business Process

What to know about the cost of custom app development

January 10, 2024

We hear a lot of ideas for apps at MichiganLabs. People from large enterprises and small startups, located all over the world, call us to explore their mobile and web-based application ideas, and one of the first questions they ask is: How much is this app going to cost?

Read more
How our Associates are using AI tools: Advice for early-career developers
Development

How our Associates are using AI tools: Advice for early-career developers

August 13, 2024

Our 2024 Associates at Michigan Labs share their experiences using AI tools like GitHub Copilot and ChatGPT in software development. They discuss how these tools have enhanced their productivity, the challenges they've faced, and provide advice for using AI effectively.

Read more
View more articles