<target name="init-test" depends="prepare">
<path id="test.classpath">
<fileset dir="${lib}">
<include name="*.jar" />
</fileset>
<pathelement location="${project.classes.build}" />
<pathelement path="${test.build}" />
<pathelement path="${test.build}/etc" />
<pathelement path="${test.build}/etc/test" />
<pathelement path="${test.build}/etc/mappings" />
</path>
<fileset id="test.fileset" dir="${test}">
<include name="**/${test.class.pattern}.java"/>
<exclude name="**/Abstract${test.class.pattern}.java"/>
<exclude name="**/Base${test.class.pattern}.java"/>
<exclude name="**/TestUtils.java"/>
</fileset>
<copy todir="${test.build}/etc/test">
<fileset dir="${etc}/test"/>
</copy>
<copy todir="${test.build}/etc/test">
<fileset dir="${etc}/mappings"/>
</copy>
<copy file="${etc}/hibernate.cfg.xml" todir="${test.build}/etc"/>
</target>
<target name="compile-test" depends="compile, run-checks">
<javac srcdir="${test}"
destdir="${test.build}"
classpathref="run.classpath"
source="${minimum.javaversion}"
target="${minimum.javaversion}"
debug="${debug.mode}"
encoding="UTF-8"
includeantruntime="no" />
<copy todir="${test.build}">
<fileset dir="${test}">
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<target name="run-test" depends="init-test, compile-test">
<mkdir dir="${test.xml}" />
<junit
haltonfailure="off"
haltonerror="off"
errorproperty="test.failed"
failureproperty="test.failed"
showoutput="no"
printsummary="yes"
includeantruntime="yes"
dir="${test.build}"
fork="true">
<jvmarg value="-Dfile.encoding=UTF8"/>
<classpath>
<path refid="test.classpath" />
</classpath>
<formatter type="xml"/>
<batchtest todir="${test.xml}">
<fileset refid="test.fileset" />
</batchtest>
</junit>
</target>
<target name="test" depends="run-test" description="Run unit tests">
<fail if="test.failed"
message="At least one test has failed. See logs (in ${test.xml}) for details (use the target test-report to run the test with a report)" />
</target>