3. Using Clover in Automated Builds


Added by Rosie Jameson, last edited by Rosie Jameson on Sep 09, 2007

Labels:

bamboo bamboo Delete
automation automation Delete
clover-pdf-report clover-pdf-report Delete
clover-check clover-check Delete
check check Delete
pdf pdf Delete
html html Delete
clover-historypoint clover-historypoint Delete
criteria criteria Delete
triggering triggering Delete
clover-report clover-report Delete
cruisecontrol cruisecontrol Delete
centipede centipede Delete
anthill anthill Delete
clover-html-report clover-html-report Delete
reporting reporting Delete
clover clover Delete
ant ant Delete
build build Delete
coverage coverage Delete
testing testing Delete
historypoint historypoint Delete
Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.
Clover 2.0 Beta Documentation

Index

In this scenario, the project is checked out, built and tested at regular intervals, usually by an automated process. Some tools that support this type of build are AntHill, Bamboo, Centipede and CruiseControl.
Clover supports this scenario with the following features:

Detailed coverage reports for the whole team

Note
The <clover-html-report> and the <clover-pdf-report> tasks used here are simplified versions of the <clover-report> task. If you require more control over your report formatting and structure, use the <clover-report> task.

In this example, the <clover-html-report> task is used to generate source-level coverage reports in HTML format that can be published for viewing by the whole team:

<target name="clover.report" depends="with.clover">
   <clover-html-report outdir="clover_html"/>
</target>







Executive summary coverage reports

In this example, the <clover-pdf-report> task is used to generate summary reports in PDF format, suitable for email or audit purposes.

<target name="clover.summary" depends="with.clover">
   <clover-pdf-report outfile="coverage.pdf"/>
</target>



Historical coverage and project metrics reporting

Clover can generate a historical snapshot of coverage and other metrics for your project using the <clover-historypoint> task. Historical data can then be colated into a historical report using the <clover-report> task:

<target name="clover.report" depends="with.clover">

   <!-- generate a historypoint for the current coverage -->
   <clover-historypoint historyDir="clover_hist"/>

   <!-- generate a report with both current and historical data -->

   <clover-html-report outdir="clover_html"
                       historyDir="clover_hist"/>
</target>



Coverage criteria checking and triggers

The <clover-check> task can be used to monitor coverage criteria. If coverage does not meet the criteria, the build can be made to fail or an arbitary activity can be triggered. In the example below, if project coverage is not 80%, an executive summary coverage report is generated and mailed to the team:

<target name="coverageAlert" depends="coverage.check"
         if="coverage_check_failure">

   <clover-pdf-report outfile="coverage.pdf"/>

   <mail from="nightlybuild@somewhere.not"
      tolist="team@somewhere.not"
      subject="coverage criteria not met"
      message="${coverage_check_failure}"
      files="coverage.pdf"/>
</target>

<target name="coverage.check" depends="with.clover">
   <clover-check target="80%"
                 failureProperty="coverage_check_failure"/>
</target>