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 and CruiseControl.
Clover supports this scenario with the following features:
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>
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>
Clover can generate a historical snapshot of coverage and other metrics for your project using the <
clover-historypoint
>
task. Historical data can then be collated 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>
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>