This documentation relates to Clover 3.1.x
If you are using an earlier version, please view the previous versions of the Clover documentation and select the relevant version.
Skip to end of metadata
Go to start of metadata

On this page:

Generating Clover Reports

Install the Clover-for-Grails plugin

Install the Clover-for-Grails plugin by running the following Grails command in the root of your Grails project directory.

For more installation options or to upgrade this plugin, please see Clover-for-Grails Installation and Upgrade Guide.

Generating a basic Clover coverage report

To generate a basic Clover code coverage report, you need to add the Clover option -clover.on to the grails test-app command line target for running unit tests against your Grails project.

Adding the Clover option -clover.view to this Grails command makes the report open in a browser window immediately after generation. If you omit this command line option, Clover will generate a report that you can then open manually.

Passing the location of your clover.license file to the grails command line

If you have not placed your clover.license file within your Grails project or user home directory (as indicated in the Installation Guide), you can pass the license file's location to the grails command line by adding the Clover option -clover.license.path=/path/to/clover.license:

Configuring Clover-for-Grails

Clover-for-Grails supports the configuration options outlined in the code sample below. All of these configuration options are defined in a single clover {} code block, which itself is defined within the Groovy build configuration file (BuildConfig.groovy) of your Grails project.

The BuildConfig.groovy file is located in the grails-app/conf subdirectory of your Grails project's root directory.

Advanced Setup Configuration

Define a setuptask 'closure' in your clover {} code block to configure advanced options for your Groovy project's build processes. Here, you can define various attributes and elements of the clover-setup task.

The setuptask closure is passed the following parameters:

  • ant — an instance of a org.codehaus.gant.GantBuilder
  • binding — the groovy binding for accessing project variables
  • plugin — the clover grails plugin that invoked this closure

The syntax used to define your clover-setup tasks in the clover {} code block is Gant.

Please be aware that some attributes and sub-elements of the clover-setup task do not support Groovy. Therefore, if your Grails project makes substantial use of Groovy code (as opposed to pure Java code, which is likely to be the case), not all features of the clover-setup task will be available to you. Refer to the clover-setup topic for details.

Advanced Report Configuration

Define a reporttask 'closure' in your clover {} code block to configure advanced report generation options for your Groovy project's build process. Here, you can define various attributes and elements of the clover-report task. In fact, any Clover Ant tasks and their attributes and elements may be used in this closure.
(info) You would not normally include clover-setup tasks in the reporttask closure because the latter is executed after the clover-setup tasks have executed.

Like the reporttask closure, the reporttask closure is passed the following parameters:

  • ant — an instance of a org.codehaus.gant.GantBuilder
  • binding — the groovy binding for accessing project variables
  • plugin — the clover grails plugin that invoked this closure

The syntax used to define your clover-report tasks or any other valid Ant task in the clover {} code block is Gant.

The following example clover {} code block and reporttask definition in your BuildConfig.groovy file will:

  • generate a Clover report in both PDF and HTML formats and
  • place the results in the build/clover/report subdirectory of your Grails project directory.

Troubleshooting

If you find that Clover-for-Grails runs out of memory, try increasing the Grails PermGen allocation by either setting the JAVA_OPTS environment variable:

Linux/UNIX/Mac OS X:
Windows:

Alternatively, you can define this variable in the startGrails (Linux/UNIX/Mac OS X) or startGrails.bat (Windows) script in the <Grails Home Directory>/bin directory.

Grails 1.2.2+ should have a larger default maximum PermGen allocation size.

RELATED TOPICS

Clover 3.0 Early Access Program
Clover-for-Grails Installation and Upgrade Guide

Labels
  • None