All Versions
Clover 4.0 DocumentationClover 3.3 Documentation
Clover 3.2 Documentation
More...
This page contains the basic steps for adding Clover's Test Optimization to an existing Ant configuration.
Follow the steps in this document to set up Clover's Test Optimization, which allows targeted testing of only the code which has changed since the last build.
These steps assume your build is Clover-enabled already (in particular it has a with.clover task already set up and has a taskdef established for the Clover Ant tasks). You will have to complement this quick start guide with basic Clover configuration information.
These steps also assume that your build file is currently used for a CI (Continuous Integration) build and possibly for general builds (e.g. On a developer's own machine). Below, we describe how you can take that build file and add sections to bake in Test Optimization. Adding optional support for Test Optimization (switching it on/off), specifying whether test minimisation is performed and test reordering other than the default 'failfast' are advanced options which are covered elsewhere.
Try to ensure your unit tests do not have dependencies between them as this may cause optimized builds to fail more frequently than usual.
<taskdef resource="cloverlib.xml" classpath="${clover.jar}"/>
<taskdef resource="cloverjunitlib.xml" classpath="${clover.jar}"/>
<PROJECT_DIR>/.clover/coverage.db.snapshot
<clover-clean/> as, by default, it won't delete snapshots. Add a property for this, as in the following example:
<property name="clover.snapshot.file" value="/path/to/clover.snapshot"/>
<target name="clover.snapshot" depends="with.clover">
<clover-snapshot file="${clover.snapshot.file}"/>
</target>
batchtest element of the <junit/> task used to test your application, so that the filesets are wrapped in the clover-optimized-testset element. See the following example:
<junit ...>
<batchtest fork="true" todir="${test.results.dir}/results">
<fileset dir="src/tests" includes="${test.includes}" excludes="${test.excludes}"/>
</batchtest>
</junit>
<junit ...>
<batchtest fork="true" todir="${test.results.dir}/results">
<clover-optimized-testset snapshotfile="${clover.snapshot.file}">
<fileset dir="src/tests" includes="${test.includes}" excludes="${test.excludes}"/>
</clover-optimized-testset>
</batchtest>
</junit>
<junit ...>
<batchtest fork="true" todir="${test.results.dir}/results">
<fileset dir="src/tests" includes="${test.includes}" excludes="${test.excludes}"/>
</batchtest>
</junit>
<junit ...>
<batchtest fork="true" todir="${test.results.dir}/results">
<fileset dir="src/tests" includes="${test.includes}" excludes="${test.excludes}">
<clover-optimized-selector snapshotfile="${clover.snapshot.file}"/>
</fileset>
</batchtest>
</junit>
clover-optimized-testset element. Ant 1.6 and clover-optimized-selector only permit the minimisation of the tests run, not optimal ordering.
ant with.clover clean run.tests clover.snapshot