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 |
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 |
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.GantBuilderbinding— the groovy binding for accessing project variablesplugin— 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.
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.GantBuilderbinding— the groovy binding for accessing project variablesplugin— 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/reportsubdirectory 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:
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






