Example script

<!-- task defs -->
<path id="testslicer.classpath">
        <fileset dir="testslicer/">
                <include name="*.jar" />
        </fileset>
</path>
<taskdef name="pick-tests" classname="br.com.caelum.testslicer.ant.PickTests" classpathref="testslicer.classpath" />
<taskdef name="update-timestamps" classname="br.com.caelum.testslicer.ant.UpdateTimestamps" classpathref="testslicer.classpath" />
<taskdef name="testslicer-instrument" classname="br.com.caelum.testslicer.ant.InstrumentTask" classpathref="testslicer.classpath" />

<!-- TODO: add your own compile -->

<!-- instrument -->

<testslicer-instrument src="target/classes"
        target="target/classes-testslicer"
        testClasses="false">
        <classpath>
                <path refid="build.classpath" />
                <path path="target/classes" />
        </classpath>
</testslicer-instrument>

<testslicer-instrument src="target/test-classes"
        target="target/test-classes-testslicer"
        testClasses="true">
        <classpath>
                <path refid="tests.classpath" />
                <path path="target/test-classes" />
        </classpath>
</testslicer-instrument>

<!-- tests -->
<fileset dir="target/test-classes-testslicer" id="unittests.fileset">
        <include name="**/*Test.class"/>
</fileset>

<pick-tests output="results.test" runFullBuildOnNoChangesDetected="true">
        <dirset dir=""> <!-- source code directory to analyze timestamps -->
                <include name="src/main/java"/>
                <include name="src/test/java"/>
        </dirset>
        <fileset refid="unittests.fileset" />
</pick-tests>

<junit fork="yes" forkmode="once" printsummary="true">
        <jvmarg line="-javaagent:testslicer/testslicer-0.9.0.jar"/>

        <classpath>
                <pathelement path="target/classes-testslicer" />
                <pathelement path="target/test-classes-testslicer" />
                <pathelement path="testslicer/*.jar" />
        </classpath>

        <batchtest fork="yes" todir="${artifacts.dir}/reports">
                <fileset dir="target/test-classes-testslicer" includesfile="results.test"/>
        </batchtest>
</junit>

<update-timestamps>
        <dirset dir="">
                <include name="src/main/java"/>
                <include name="src/test/java"/>
        </dirset>
</update-timestamps>