|
|
@@ -354,6 +354,12 @@ can be specified.</p> |
|
|
|
that your tests have written as some characters are illegal in XML |
|
|
|
documents and will be dropped.</p> |
|
|
|
|
|
|
|
<p>The formatter named <code>failure</code> collects all failing <code>testXXX()</code> |
|
|
|
methods and creates a new <code>TestCase</code> which delegates only these |
|
|
|
failing methods. The name and the location can be specified via Java System property |
|
|
|
<code>ant.junit.failureCollector</code>. The value has to point to the directory and |
|
|
|
the name of the resulting class (without suffix). It defaults to <i>java-tmp-dir</i>/FailedTests.</p> |
|
|
|
|
|
|
|
<p><b>Note:</b> Please read the <a |
|
|
|
href="../../faq.html#junit-no-runtime-xml">Ant FAQ</a> if you want to |
|
|
|
set the fork attribute to <code>true</code>, the includeAntRuntime |
|
|
@@ -616,6 +622,50 @@ aborted. Results are collected in files named |
|
|
|
<code>TEST-</code><em>name</em><code>.txt</code> and written to |
|
|
|
<code>${reports.tests}</code>.</p> |
|
|
|
|
|
|
|
<pre> |
|
|
|
<target name="test"> |
|
|
|
<property name="collector.dir" value="${build.dir}/failingTests"/> |
|
|
|
<property name="collector.class" value="FailedTests"/> |
|
|
|
<!-- Delete 'old' collector classes --> |
|
|
|
<delete> |
|
|
|
<fileset dir="${collector.dir}" includes="${collector.class}*.class"/> |
|
|
|
</delete> |
|
|
|
<!-- compile the FailedTests class if present --> |
|
|
|
<javac srcdir="${collector.dir}" destdir="${collector.dir}"/> |
|
|
|
<available file="${collector.dir}/${collector.class}.class" property="hasFailingTests"/> |
|
|
|
<junit haltonerror="false" haltonfailure="false"> |
|
|
|
<sysproperty key="ant.junit.failureCollector" value="${collector.dir}/${collector.class}"/> |
|
|
|
<classpath> |
|
|
|
<pathelement location="${collector.dir}"/> |
|
|
|
</classpath> |
|
|
|
<batchtest todir="${collector.dir}" unless="hasFailingTests"> |
|
|
|
<fileset dir="${collector.dir}" includes="**/*.java" excludes="**/${collector.class}.*"/> |
|
|
|
<!-- for initial creation of the FailingTests.java --> |
|
|
|
<formatter type="failure"/> |
|
|
|
<!-- I want to see something ... --> |
|
|
|
<formatter type="plain" usefile="false"/> |
|
|
|
</batchtest> |
|
|
|
<test name="FailedTests" if="hasFailingTests"> |
|
|
|
<!-- update the FailingTests.java --> |
|
|
|
<formatter type="failure"/> |
|
|
|
<!-- again, I want to see something --> |
|
|
|
<formatter type="plain" usefile="false"/> |
|
|
|
</test> |
|
|
|
</junit> |
|
|
|
</target> |
|
|
|
</pre> |
|
|
|
<p>On the first run all tests are collected via the <code><batchtest/></code> |
|
|
|
element. It's <code>plain</code> formatter shows the output on the console. The |
|
|
|
<code>failure</code> formatter creates a java source file in |
|
|
|
<code>${build.dir}/failingTests/FailedTests.java</code> which extends |
|
|
|
<code>junit.framework.TestCase</code> and returns from a <code>suite()</code> |
|
|
|
method a test suite for the failing tests. <br/> |
|
|
|
On a second run the collector class exists and instead of the <code><batchtest/></code> |
|
|
|
the single <code><test/></code> will run. So only the failing test cases are re-run. |
|
|
|
The two nested formatters are for displaying (for the user) and for updating the collector |
|
|
|
class. |
|
|
|
</p> |
|
|
|
|
|
|
|
|
|
|
|
</body> |
|
|
|
</html> |