This documentation relates to an earlier version of Clover.
View this page in the current documentation or visit the current documentation home.
Skip to end of metadata
Go to start of metadata

Getting started with Clover-for-Ant

This section shows you how to quickly get Clover integrated into your build. Clover instrumentation and reporting are highly configurable so later sections of this manual will detail available configuration options and typical usage scenarios.

Unless otherwise indicated, all configuration options throughout this User's Guide apply to both Java and Groovy.

Using Ant 1.7? See the even faster Clover Two Line Integration page.

Follow these simple steps to integrate Clover with your build:

1. Install Clover

1.1 Ensure you are using a recent version of Ant.

1.2 Download Clover from http://www.atlassian.com/software/clover/CloverDownloadCenter.jspa.

1.3 Unzip the Clover distribution into a directory. This directory will be referred to as CLOVER_HOME in this guide.

1.4 Place your clover.license file in CLOVER_HOME/lib.

2. Add Clover targets

Edit build.xml for your project:

2.1 Add the Clover Ant tasks to your project:

2.2 Add a target to switch on Clover:

2.3 Add one or more targets to run Clover reports:

For HTML reporting, use the following (but change the outdir to a directory path where Clover should put the generated HTML):

OR, for PDF reporting, use the following (but change the outfile to a file where Clover should write the PDF file):

OR, for XML reporting, use the following (but change the outfile to a file where Clover should write the XML file):

OR, for simple emacs-style reporting to the console, try:

2.4 Add clover.jar to the runtime classpath for your tests. How you do this depends on how you run your tests. For tests executed via the <junit> task, add a <classpath> element:

Compile and run with Clover

Now you can build your project with Clover turned on by adding the "with.clover" target to the list of targets to execute. For example (if your compile target is named 'build' and your unit test target is named 'test'):

Generate a Coverage Report

To generate a Clover coverage report:

For a sample report, see 'Current' Report.

NEXT STEPS

See the Test Optimization Quick Start Guide, for how to set up Clover's Test Optimization feature to streamline your testing.

FURTHER READING

See Clover for Ant Best Practices.