To take advantage of this feature all you need to do is:
<
clover-setup
>
task.If you are using a testing framework which does not use Junit or TestNG conventions for determining test methods, the nested <testsources/>
element of <
clover-setup
>
and <
clover-instr
>
will allow you to specify the convention used by your framework.
The Instinct framework for example uses the following:
<clover-setup> <testsources dir="tests"> <testclass> <testmethod annotation="Specification"/> <testmethod name="^should.*"/> <testmethod name="^must.*"/> </testclass> </testsources> </clover-setup>
You can optionally group <testclass/>
definitions in <or/>
or <and/>
elements. Each <testmethod/>
element is automatically grouped by an OR.
<clover-setup> <testsources dir="tests"> <or> <testclass name=".*Context"> <testmethod annotation="Specification"/> </testclass> <testclass name=".*Test"> <testmethod name="test.*"/> </testclass> </or> </testsources> </clover-setup>
Differences between Groovy and Java with respect to <clover-setup> tasks.
Clover does its best to record your test results in the Clover database. In some instances however, Clover can not always do so. Although unit tests using @Test(expected=Exception.class)
annotations will be marked as passed, more novel JUnit constructs such as rules may not be recognized and Clover will flag those tests as failed when in fact they passed. To integrate these test results into your Clover reports follow these steps:
Enable XML reports from your Unit Test execution.
In an Ant build, if using the <junit>
task, you need to add an XML result formatter:
<property name="testreport.dir" value="build/test-reports"> <junit ...> ... <formatter type="xml"/> <batchtest todir="${testreport.dir}"> ... </batchtest> </junit>
Such results can be similarly produced by the Ant TestNG tasks.
<testresults>
element at report time.<testresults>
element is specified, <
clover-report
>
and similar tasks will use these results instead of those collected by Clover. Clover's test result collection may also be switched off via the dontRecordTestResults
attribute on <
clover-setup
>
or <
clover-instr
>
.e.g.
<testresults dir="test-results" include="TEST-*.xml"/>
Clover's per-test coverage collection does not support parallel test execution.