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.
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…