Part 0 - Clover in 10 minutes

Still need help?

The Atlassian Community is here for you.

Ask the community

License

Make sure that <clover_installation_dir>/lib/clover.license file exists next to clover.jar file and contains a 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: .../tutorial/build_quick.xml

init:
    [mkdir] Created dir: .../tutorial/lib
      [get] Getting: https://repo1.maven.org/maven2/junit/junit/4.12/junit-4.12.jar
      [get] To: .../tutorial/lib/junit-4.12.jar

with.clover:
[clover-setup] Clover Version 4.1.0, built on ...
[clover-setup] Loaded from: .../lib/clover.jar
[clover-setup] Clover: Site License registered to ...
[clover-setup] Clover is enabled with initstring '.../tutorial/build/clover/db/clover.db'

compile:
    [mkdir] Created dir: .../tutorial/build/classes
    [javac] Compiling 3 source files to .../tutorial/build/classes
   [clover] Clover Version 4.1.0, built on ...
   [clover] Loaded from: .../lib/clover.jar
   [clover] Clover: Site License registered to ...
   [clover] Creating new database at '.../tutorial/build/clover/db/clover.db'.
   [clover] Processing files at 1.8 source level.
   [clover] Clover all over. Instrumented 3 files (1 package).
   [clover] Elapsed time = 0.091 secs. (32.967 files/sec, 3,142.857 srclines/sec)
    [mkdir] Created dir: .../tutorial/build/testclasses
    [javac] Compiling 2 source files to .../tutorial/build/testclasses
   [clover] Clover Version 4.1.0, built on October 28 2015 (build-dev)
   [clover] Loaded from: .../lib/clover.jar
   [clover] Clover: Site License registered to ...
   [clover] Updating existing database at '.../tutorial/build/clover/db/clover.db'.
   [clover] Processing files at 1.8 source level.
   [clover] Clover all over. Instrumented 2 files (1 package).
   [clover] 23 test methods detected.
   [clover] Elapsed time = 0.041 secs. (48.78 files/sec, 4,682.927 srclines/sec)

test:
    [mkdir] Created dir: .../tutorial/build/testresults
    [junit] Running com.atlassian.samples.money.MoneyBagTest
    [junit] Tests run: 22, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.072 sec
    [junit] Running com.atlassian.samples.money.MoneyTest
    [junit] Tests taking too long? Try Clover's test optimization.
    [junit] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.063 sec

clover.report:
[clover-html-report] Clover Version 4.1.0, built on ...
[clover-html-report] Loaded from: .../lib/clover.jar
[clover-html-report] Clover: Site License registered to ...
[clover-html-report] Loading coverage database from: '.../tutorial/build/clover/db/clover.db'
[clover-html-report] Writing HTML report to '.../tutorial/build/clover_html'
[clover-html-report] Done. Processed 1 packages in 1089ms (1089ms per package).

BUILD SUCCESSFUL

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/build/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

Last modified on Dec 8, 2015

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.