Member-only story

Code Coverage with OpenClover for Java code in CI/CD

How to set up OpenClover for Apache Ant and run in a CI/CD server.

Zhimin Zhan
6 min readMay 30, 2022

A repost of my daughter’s article with permission and extra: introducing code coverage in a Continuous Testing server.

Lately, I have been looking into code coverage solutions in Java. I initially tried Cobertura coverage library, but it was a pain to get all its dependent libraries (many of them) and it was incompatible with Java 17. So, I tried Clover and found it was much easier to set up. Clover was acquired by Atlassian (renamed Atlassian Clover) in 2007 but was turned open source in 2017 (this version is named OpenClover).

This tutorial will show you how to set up OpenClover with Apache Ant.

Table of Contents
· Demonstration
Commands you can run yourself
· Setting up OpenClover
· Run with Ant and Generate Your Clover Report
· Full Build.xml
· Run code coverage in CI/CD or CT server
Coverage Check

Note that OpenClover has its own Apache Ant installation guide. However, I had some trouble with the generating the build report when I followed the guide so I have written this article.

Demonstration

Below (animated GIF) is a run of the Clover code coverage for my sample Java

--

--

Zhimin Zhan
Zhimin Zhan

Written by Zhimin Zhan

Test automation & CT coach, author, speaker and award-winning software developer. Help teams succeed with Agile/DevOps by implementing real Continuous Testing.

No responses yet