This is the documentation for Clover 3.3. View this page for the

Unknown macro: {spacejump}

of Clover, or visit the latest Clover documentation.

Requirement

This tutorial requires at least Clover 3.1.12 which contains pre-configured tutorial project (specifically Ant build_quick.xml file).

License

Make sure that clover_installation_dir/lib/clover.license file exists next to clover.jar file and contains valid license.

Welcome to the Clover-for-Ant 10 minutes tutorial. This document will show you how to quickly get Clover reports for sample project.

On this page:

Introduction

In this tutorial we will generate Clover HTML report for Money library provided in the tutorial/src directory.

Generating report

The process of generating report contains few phases, configured to be executed with single Ant command for the purpose of this tutorial:

  • Compiling project (and instrumenting its source code with Clover statements).
  • Running unit tests (and gathering code coverage).
  • Generating code coverage report.

Running Ant command

To generate report, use the command ant -f build_quick.xml

Output should be similar to the following:

$ ant -f  build_quick.xml
 Buildfile:  build_quick.xml

 with.clover:    
    [clover-setup] Clover Version 3.1.12, built on ...
    [clover-setup] Loaded from: C:\ant\lib\clover.jar    
    [clover-setup] Site License registered to ...
    [clover-setup] Clover is enabled with initstring 'C:\clover\tutorial\.clover\clover2_X.db'
 
 code.compile:
    [mkdir] Created dir: C:\clover\tutorial\build
    [javac] Compiling 4 source files to C:\clover\tutorial\build
    [clover] Clover Version 3.1.12, built on ...
    [clover] Loaded from: C:\ant\lib\clover.jar
    [clover] Site License registered to ...
    [clover] Processing files at 1.4 source level.
    [clover] Clover all over. Instrumented 4 files.

 test.compile:
   [mkdir] Created dir: C:\clover\tutorial\build\test
   [javac] Compiling 2 source files to C:\clover\tutorial\build\test
   [clover] Clover Version 3.1.12, built on ...
   [clover] Loaded from: C:\ant\lib\clover.jar
   [clover] Site License registered to ...
   [clover] 23 test methods detected.

 test.run:
   [mkdir] Created dir: C:\clover\tutorial\build\testresult
   [junit] Running MoneyBugTest
   [junit] Tests run: 22, Failures: 0, Errors: 0, Time elapsed: 0.346 sec

 clover.report:    
    [clover-html-report] Clover Version 3.1.12, built on ...
    [clover-html-report] Loaded from: C:\ant\lib\clover.jar
    [clover-html-report] Site License registered to ...
    [clover-html-report] Loading coverage database from: ...
    [clover-html-report] Writing report to 'C:\clover\tutorial\clover_html'
    [clover-html-report] Done. Processed 1 packages.

 BUILD SUCCESSFUL
 Total time: 9 seconds

This shows that the java source files have been compiled and instrumented, tests have been executed and Clover report generated.

Opening report

You can now view the report by opening the file tutorial/clover_html/index.html in a web browser. See 'Current' Report for details about interpreting this coverage report.

Uncovering details

If you want to understand what happened under the hood and how to customize and adjust the process of getting reports, please continue with Part 1 - Measuring Coverage