<clover-report>
Description
Generates current and historical reports in multiple formats. The basic nesting of elements within the <clover-report> task is as follows:
<clover-report> <current> <fileset/> <sourcepath/> <format/> </current> <historical> <format/> <overview/> <coverage/> <metrics/> <movers/> </historical> </clover-report>
Parameters
| Attribute | Description | Required |
| initstring | The initstring of the coverage database. | No; If not specified here, you must ensure <clover-setup> is called prior the execution of this task. |
| failOnError | If true, failure to generate a report causes a build failure. | No; defaults to "true". |
Nested elements of <clover-report>
These elements represent the actual reports to be generated. You can generate multiple reports by specifying more than one of these inside a <clover-report> element.
<current>
Generates a current coverage report. Specify the report format using a nested Format element. Valid formats are XML, HTML, and PDF although not all configurations support all formats. The default format is PDF if summary="true" or XML if not. See Current Report examples.
Parameters
| Attribute | Description | Required |
| title | Specifies a title for the report. | No |
| titleAnchor | if specified, the report title will be rendered as a hyperlink to this href. | No; default is to not render the report title as a hyperlink. |
| titleTarget | Specifies the href target if the title is to be rendered as a hyperlink (see titleAnchor above). HTML format only | No; default is "_top" |
| alwaysReport | If set to true, a report will be generated even in the absence of coverage data. | No; defaults to "false" |
| outfile | The outfile to write output to. If it does not exist, it is created. Depending on the specified format, this either represents a regular file (PDF, XML) or a directory (HTML). | Yes |
| summary | Specifies whether to generate a summary report or detailed report. | No; Defaults to "false". |
| package | Restricts the report to a particular package. | No |
| span | Specifies how far back in time to include coverage recordings from since the last Clover build. See Using Spans. | No; Defaults to "0s". |
<historical>
Generates a historical coverage report. Specify the report format using a nested Format element. Valid formats are HTML or PDF. The default format is PDF. Contents of the historical report are optionally controlled by nested elements. See Nested elements of Historical.
Parameters
| Attribute | Description | Required |
| title | Specifies a title for the report. | No |
| titleAnchor | if specified, the report title will be rendered as a hyperlink to this href. | No; default is to not render the report title as a hyperlink. |
| titleTarget | Specifies the href target if the title is to be rendered as a hyperlink (see titleAnchor above). HTML format only | No; default is "_top" |
| outfile | The outfile to write output to. If it does not exist, it is created. Depending on the specified format, this either represents a regular file (PDF) or a directory (HTML). | Yes |
| historyDir | The directory containing Clover historical data as produced by the <clover-historypoint> task. | Yes |
| package | Restricts the report to a particular package. | No |
| from | Specifies the date before which data points will be ignored. The date must be specified either using the default java.text.SimpleDateFormat for your locale or using the pattern defined in the "dateFormat" attribute. | No |
| to | Specifies the date after which data points will be ignored. The date must be specified either using the default java.text.SimpleDateFormat for your locale or using the pattern defined in the "dateFormat" attribute. | No |
| dateFormat | Specifies a date format string for parsing the "from" and "to" fields. The string must contain a valid java.text.SimpleDateFormat pattern. | No; default set to java.text.SimpleDateFormat using the default pattern and date format symbols for the default locale. |
Nested elements of<current>
<fileset>
<current> supports nested filesets which control which source files are to be included in a report. Only classes which are from the source files in the fileset are included in the report. This allows reports to focus on certain packages or particular classes. By using Ant's fileset selectors, more complicated selections are possible, such as the files which have recently changed, or files written by a particular author.
<sourcepath>
Specifies a Ant path that Clover should use when looking for source files.
Nested elements of <historical>
These elements represent individual sections of the historical report. If you do not specify any of these elements, all the sections will be included in the report. If you specify more one or more of these elements, only the specified sections will be included. You may specify multiple <overview> and <coverage> elements in the historical report. These may have different properties and include different elements. The charts will appear in the report in the same order they appear in the <historical> element. The <movers> element always appears at the end of the report following these charts regardless of its location in the <historical> element. <historical> element.
<overview>
Specifies a section that provides summary of the total percentage coverage at the last history point. This element does not support any attributes.
<coverage>
Specifies a chart showing percentage coverage over time.
Parameters
| Attribute | Description | Required |
| include | A comma or space separated list of coverage metrics to include in the chart. Valid values are: branches, statements, methods, total | No; the default is that everything is included |
<metrics>
Specifies a chart showing other metrics over time.
Parameters
| Attribute | Description | Required |
| include | A comma or space separated list of metrics to include in the chart. Valid values are: loc, ncloc, statements, methods, classes, files, packages | No; defaults to loc, ncloc, methods, classes |
| logscale | Specifies that a log scale be used on the Range Axis. This can be useful if you are including, say LOC and packages in the same chart. | No; default is "true" |
<movers>
Specifies a table that shows those classes that have a coverage delta higher than a specified threshold over a specified time preiod.
Parameters
| Attribute | Description | Required |
| threshold | The absolute point change in percent coverage that class must have changed by for inclusion. e.g "10%". | No; defaults to 1% |
| range | The maximum number of classes to show. If the value is 5, then a maximum of 5 "gainers" and 5 "losers" will be shown. | No; The defaults to 5 |
| interval | The time interval over which the delta should be calculated (from the last history point). Uses the Interval format. The range is automatically adjusted to the closest smaller interval available. | No; The default is to take the delta of the last two history points |
The <format> Element
Specifies the output format and various options controlling the rendering of a report.
Parameters
| Attribute | Description | Required |
| type | The output format to render the report in. Valid values are pdf, xml, html. Note that not all reports support all formats. | Yes, unless refid is set |
| refid | the id of another format element that will be used for this report. See Sharing Report Formats. | No |
| id | the id of this format element. | No |
| bw | Specify that the report should be black and white. This will make HTML reports smaller (with no syntax hilighting) and make PDF reports suitable for printing on a non-colour printer. | No; defaults to "false" |
| orderBy | Specify how to order coverage tables. This attribute
has no effect on XML format. Valid values are:
|
No; defaults to PcCoveredAsc |
| noCache | (HTML only) if true, insert nocache directives in html output. | No; defaults to "false" |
| srcLevel | if true, include source-level coverage information in the report. | No; defaults to "true" |
| filter | comma or space separated list of contexts to exclude when generating coverage reports. See Using Contexts. | No |
| pageSize | (PDF only) Specify the page size to use. Valid values are A4, LETTER | No; defaults to "A4" |
| showEmpty | If true, classes, files and packages that do not contain any executable code (i.e. methods, statements, or branches) are included in reports. These are normally not shown. | No; defaults to "false" |
| tabWidth | (Source level reports only) The number of space chars to replace TAB characters with. | No; defaults to 4 |
| maxNameLength | The maximum length in chars of package or classnames in the report. Longer names will be truncated. A value < 0 indicates no limit. | No; defaults to no limit |
Examples of Current Report Configurations
<clover-report>
<current outfile="current.xml"/>
</clover-report>
Generates an XML report of the current coverage.
<clover-report>
<current outfile="current.pdf">
<format type="pdf"/>
</current>
</clover-report>
Generates a PDF report of the current coverage.
<clover-report>
<current outfile="clover_html" title="My Project" summary="true">
<format type="html"/>
</current>
</clover-report>
Generates a summary report, in HTML with a custom title. Note, the "outfile" argument requires a directory instead of a filename.
<clover-report>
<current outfile="clover_html" title="Util Coverage">
<format type="html" orderBy="ElementsCoveredAsc"/>
</current>
</clover-report>
Generates a detailed coverage report in HTML with output ordered by total number of covered elements, rather than percentage coverage.
<clover-report>
<current outfile="clover_html" title="My Project">
<format type="html"/>
<sourcepath>
<pathelement path="/some/other/location"/>
</sourcepath>
</current>
</clover-report>
Generates a sourcelevel report in HTML. Clover will search for source files in the directory /some/other/location.
<tstamp>
<format property="report.limit" pattern="MM/dd/yyyy hh:mm aa"
offset="-1" unit="month"/>
</tstamp>
<clover-report>
<current outfile="report-current"
title="Coverage since ${report.limit}">
<fileset dir="src/main">
<date datetime="${report.limit}" when="after"/>
</fileset>
<format srclevel="true" type="html"/>
</current>
</clover-report>
This example generates a current coverage report for all files in the project that have changed in the last month. Replacing the <date> selector with <contains text="@author John Doe"/> would generate a coverage report for all code where John Doe is the author.
<clover-report>
<current outfile="report-current" title="Coverage">
<fileset dir="src">
<patternset refid="clover.files"/>
</fileset>
<format srclevel="true" type="html"/>
</current>
</clover-report>
In this example the standard Clover patternset is used to restrict the report to the currently included source files. You could use this if you have changed the exclude or include definitions in the <clover-setup> task and you have not removed the coverage database. It will prevent classes, currently in the database but now excluded, from being included in the report. It is prudent, however, to delete the coverage databse, coverage information and recompile when you change these settings.
Examples of Historical Report Configurations
<clover-report>
<historical outfile="historical.pdf"
historyDir="clover_history">
</historical>
</clover-report>
Generates a historical report in PDF. Assumes that <clover-historypoint> has generated more than one history file in the directory "clover_history". Writes the output to the file specified in the outfile parameter.
<clover-report>
<historical outfile="two_months" title="My Project"
from="020101" to="020301" dateFormat="yyMMdd"
historyDir="clover_history">
<format type="html"/>
</historical>
</clover-report>
Generates a basic historical report in HTML for a certain time period. Clover will scan the history dir and use any history points that fall within the requested time period. The outfile attribute will be treated as a directory; a file historical.html will be written into this directory. If the directory doesn't exist, it will be created.
<clover-report>
<historical outfile="report.pdf" title="My Project"
historyDir="clover_history">
<overview/>
<movers threshold="5%" range="20" interval="2w"/>
</historical>
</clover-report>
Generates a PDF historical report that only includes an overview section (showing summary coverage at the last history point) and a movers table showing classes that have a code coverage delta of greater than +- 5% over the two weeks prior to the last history point. Will include at most 20 gainers and 20 losers.
