1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
|
<project default="test" xmlns:junit4="antlib:com.carrotsearch.junit4">
<presetdef name="javac">
<javac deprecation="false" debug="true" encoding="UTF-8" includeantruntime="false" />
</presetdef>
<property name="tmp.dir" location="${basedir}/target" />
<!--
This setup is a bit complex because it needs to work for integration tests and for distribution examples.
-->
<target name="classpath.resolve">
<available property="libs.dir" value="${basedir}/target/lib" file="${basedir}/target/lib" type="dir" />
<available property="libs.dir" value="${basedir}/../../lib" file="${basedir}/../../lib" type="dir" />
<fail message="No classpath?">
<condition>
<not>
<isset property="libs.dir" />
</not>
</condition>
</fail>
</target>
<!--
Compile the sources from maven examples to avoid duplication.
-->
<target name="compile" depends="classpath.resolve">
<mkdir dir="${tmp.dir}/classes" />
<javac destdir="${tmp.dir}/classes">
<src location="${basedir}/../maven/src/main/java" />
<classpath>
<fileset dir="${libs.dir}" includes="*.jar" />
</classpath>
</javac>
</target>
<!--
Run the test.
-->
<target name="test" depends="classpath.resolve,compile">
<!-- Make room for tests output and report. -->
<delete dir="${tmp.dir}" failonerror="false" quiet="true">
<include name="test-report*/**" />
</delete>
<!--
Load JUnit4. This can be loaded as an antlib or into the default
namespace using resource=com/carrotsearch/junit4/antlib.xml
-->
<taskdef uri="antlib:com.carrotsearch.junit4">
<classpath>
<fileset dir="${libs.dir}">
<include name="junit4-ant*.jar" />
<include name="junit-*.jar" />
</fileset>
</classpath>
</taskdef>
<!--
Run junit4 tests.
-->
<junit4:junit4 jvm="" dir="${tmp.dir}" maxmemory="50m" haltonfailure="false" failureProperty="tests.failed" parallelism="1" shuffleOnSlave="true" leaveTemporary="false" seed="" printSummary="false">
<classpath>
<pathelement location="${tmp.dir}/classes" />
<fileset dir="${libs.dir}" includes="*.jar" />
</classpath>
<!--
Test selector. junit4 supports *.class files (and these are preferred over .java files).
-->
<fileset dir="${tmp.dir}/classes">
<include name="**/Test*.class" />
<exclude name="**/*$*" />
</fileset>
<!-- Nested elements much like in "standard" ANT 'junit' task. -->
<jvmarg value="-ea" />
<jvmarg value="-Dfoo=bar" />
<sysproperty key="foo" value="bar" />
<env key="env.foo" value="bar" />
<assertions>
<enable package="com.carrotsearch" />
</assertions>
<!-- Attached listeners -->
<listeners>
<!--
'verbose' config in which each suite and its test case is individually
shown along with its output, exceptions, stack traces etc.
-->
<junit4:report-text file="${tmp.dir}/test-report-txt/results-verbose.txt"
showThrowable="true"
showStackTraces="true"
showOutput="always"
showStatusOk="true"
showStatusError="true"
showStatusFailure="true"
showStatusIgnored="true"
showSuiteSummary="true" />
<!--
'suite' maven-like output in which each test case is individually shown along
with its output. No exceptions or stacks.
-->
<junit4:report-text file="${tmp.dir}/test-report-txt/results-suite.txt"
showThrowable="false"
showStackTraces="false"
showOutput="never"
showStatusOk="false"
showStatusError="false"
showStatusFailure="false"
showStatusIgnored="false"
showSuiteSummary="true" />
<!--
'quiet' output in which only errors are shown (without stacks).
-->
<junit4:report-text file="${tmp.dir}/test-report-txt/results-quiet.txt"
showThrowable="true"
showStackTraces="false"
showOutput="onerror"
showStatusOk="false"
showStatusError="true"
showStatusFailure="true"
showStatusIgnored="false"
showSuiteSummary="false" />
<!--
All tests with status information.
-->
<junit4:report-text file="${tmp.dir}/test-report-txt/results-testlist.txt"
showThrowable="false"
showStackTraces="false"
showOutput="never"
showStatusOk="true"
showStatusError="true"
showStatusFailure="true"
showStatusIgnored="true"
showSuiteSummary="false" />
<!-- JSON report with HTML scaffolding. -->
<junit4:report-json file="${tmp.dir}/test-report-json/results.html" />
<!-- XML reports compatible with ant-report task. -->
<junit4:report-ant-xml dir="${tmp.dir}/test-report-xml" />
</listeners>
</junit4:junit4>
<!-- Run a "standard" JUnit report on the generated XML files. JSON report is recommended. -->
<junitreport todir="${tmp.dir}/test-report-xml">
<fileset dir="${tmp.dir}/test-report-xml">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${tmp.dir}/test-report-xml" />
</junitreport>
<echo>
Done. See reports under target/.
</echo>
</target>
</project>
|