2000-08-09 13:12:13 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
2002-02-03 22:11:39 +00:00
|
|
|
<title>JUnit Task</title>
|
2000-08-09 13:12:13 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<h2><a name="junit">JUnit</a></h2>
|
|
|
|
<h3>Description</h3>
|
|
|
|
|
|
|
|
<p>This task runs tests from the JUnit testing framework. The latest
|
2002-03-14 01:01:18 +00:00
|
|
|
version of the framework can be found at
|
2000-09-20 15:22:00 +00:00
|
|
|
<a href="http://www.junit.org">http://www.junit.org</a>.
|
2002-09-06 06:16:39 +00:00
|
|
|
This task has been tested with JUnit 3.0 up to JUnit 3.8.1; it won't
|
2001-05-22 09:20:17 +00:00
|
|
|
work with versions prior to JUnit 3.0.</p>
|
2002-03-14 01:01:18 +00:00
|
|
|
<p><strong>Note:</strong> This task depends on external libraries not included
|
|
|
|
in the Ant distribution. See <a href="../install.html#librarydependencies">
|
|
|
|
Library Dependencies</a> for more information.
|
|
|
|
</p>
|
2002-03-20 00:02:15 +00:00
|
|
|
<p>
|
|
|
|
<strong>Note</strong>:
|
|
|
|
You must have <code>junit.jar</code> and the class files for the
|
|
|
|
<code><junit></code> task in the same classpath.
|
|
|
|
You can do one of:
|
|
|
|
<ol>
|
|
|
|
<li>
|
|
|
|
Put both <code>junit.jar</code> and the optional tasks jar file in
|
|
|
|
<code>ANT_HOME/lib</code>.
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
Do not put either in <code>ANT_HOME/lib</code>, and instead
|
|
|
|
include their locations in your <code>CLASSPATH</code> environment variable.
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
Do neither of the above, and instead, specify their locations using
|
|
|
|
a <code><classpath></code> element in the build file.
|
|
|
|
|
2002-04-18 14:48:13 +00:00
|
|
|
See <a href="../../faq.html#delegating-classloader" target="_top">the
|
|
|
|
FAQ</a> for details.
|
2002-03-20 00:02:15 +00:00
|
|
|
</ol>
|
|
|
|
</p>
|
|
|
|
|
2000-08-09 13:12:13 +00:00
|
|
|
|
|
|
|
<p>Tests are defined by nested <code>test</code> or
|
2002-03-20 00:02:15 +00:00
|
|
|
<code>batchtest</code> tags (see <a href="#nested">nested
|
|
|
|
elements</a>).</p>
|
2000-08-09 13:12:13 +00:00
|
|
|
|
|
|
|
<h3>Parameters</h3>
|
|
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<td width="12%" valign="top"><b>Attribute</b></td>
|
|
|
|
<td width="78%" valign="top"><b>Description</b></td>
|
|
|
|
<td width="10%" valign="top"><b>Required</b></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">printsummary</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">Print one-line statistics for each testcase. Can
|
|
|
|
take the values <code>on</code>,
|
|
|
|
<code>off</code>, and
|
|
|
|
<code>withOutAndErr</code>.
|
|
|
|
<code>withOutAndErr</code> is the same
|
|
|
|
as <code>on</code> but also includes the output of the test
|
|
|
|
as written to <code>System.out</code> and <code>System.err</code>.</td>
|
|
|
|
<td align="center" valign="top">No; default is <code>off</code>.</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">fork</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
<td valign="top">Run the tests in a separate VM.</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td align="center" valign="top">No; default is <code>off</code>.</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">haltonerror</td>
|
2000-08-09 15:50:23 +00:00
|
|
|
<td valign="top">Stop the build process if an error occurs during the test
|
2000-08-09 13:12:13 +00:00
|
|
|
run.</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td align="center" valign="top">No; default is <code>off</code>.</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
</tr>
|
2001-07-17 13:09:48 +00:00
|
|
|
<tr>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">errorproperty</td>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">The name of a property to set in the event of an error.</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
2001-07-17 13:09:48 +00:00
|
|
|
</tr>
|
2000-08-09 13:12:13 +00:00
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">haltonfailure</td>
|
|
|
|
<td valign="top">Stop the build process if a test fails (errors are
|
2000-08-09 13:12:13 +00:00
|
|
|
considered failures as well).</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td align="center" valign="top">No; default is <code>off</code>.</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
</tr>
|
2001-07-17 13:09:48 +00:00
|
|
|
<tr>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">failureproperty</td>
|
2001-07-17 13:09:48 +00:00
|
|
|
<td valign="top">The name of a property to set in the event of a failure
|
2002-03-14 01:01:18 +00:00
|
|
|
(errors are considered failures as well).</td>
|
2001-07-17 13:09:48 +00:00
|
|
|
<td align="center" valign="top">No.</td>
|
|
|
|
</tr>
|
2001-12-09 13:40:18 +00:00
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">filtertrace</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">Filter out Junit and Ant stack frames from error and failure stack traces.</td>
|
|
|
|
<td align="center" valign="top">No; default is <code>on</code>.</td>
|
2001-12-09 13:40:18 +00:00
|
|
|
</tr>
|
2000-08-09 13:12:13 +00:00
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">timeout</td>
|
2003-09-10 10:00:14 +00:00
|
|
|
<td valign="top">Cancel the individual tests if they don't finish
|
2002-03-20 00:02:15 +00:00
|
|
|
in the given time (measured in milliseconds). Ignored if
|
|
|
|
<code>fork</code> is disabled.</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">maxmemory</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">Maximum amount of memory to allocate to the forked VM.
|
|
|
|
Ignored if <code>fork</code> is disabled.</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">jvm</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">The command used to invoke the Java Virtual Machine,
|
|
|
|
default is 'java'. The command is resolved by
|
|
|
|
<code>java.lang.Runtime.exec()</code>.
|
|
|
|
Ignored if <code>fork</code> is disabled.</td>
|
|
|
|
<td align="center" valign="top">No; default is <code>java</code>.</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
</tr>
|
2000-09-19 16:25:40 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">dir</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">The directory in which to invoke the VM. Ignored if
|
|
|
|
<code>fork</code> is disabled.</td>
|
2000-09-19 16:25:40 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
2002-01-29 16:35:46 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">newenvironment</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">Do not propagate the old environment when new
|
|
|
|
environment variables are specified. Ignored if <code>fork</code> is
|
2002-01-29 16:35:46 +00:00
|
|
|
disabled.</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td align="center" valign="top">No; default is <code>false</code>.</td>
|
2002-01-29 16:35:46 +00:00
|
|
|
</tr>
|
2002-02-26 10:11:19 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">includeantruntime</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">Implicitly add the Ant classes required to run
|
2002-02-26 10:11:19 +00:00
|
|
|
the tests and JUnit to the classpath in forked mode.</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td align="center" valign="top">No; default is <code>true</code>.</td>
|
2002-02-26 10:11:19 +00:00
|
|
|
</tr>
|
2002-04-18 09:49:55 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">showoutput</td>
|
|
|
|
<td valign="top">Send any output generated by tests to Ant's
|
|
|
|
logging system as well as to the formatters. By default only the
|
|
|
|
formatters receive the output.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
2003-03-31 12:27:14 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">tempdir</td>
|
|
|
|
<td valign="top">Where Ant should place temporary files.
|
|
|
|
<em>Since Ant 1.6</em>.</td>
|
|
|
|
<td align="center" valign="top">No; default is the project's base
|
|
|
|
directory.</td>
|
|
|
|
</tr>
|
2003-06-20 16:29:53 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">reloading</td>
|
|
|
|
<td valign="top">Whether or not a new classloader should be instantiated for each test case.<br/>
|
|
|
|
Ignore if <code>fork</code> is set to true.
|
|
|
|
<em>Since Ant 1.6</em>.</td>
|
|
|
|
<td align="center" valign="top">No; default is <code>true</code>.</td>
|
|
|
|
</tr>
|
2004-04-06 14:09:25 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">clonevm</td>
|
|
|
|
<td valign="top">If set to true true, then all system properties
|
|
|
|
and the bootclasspath of the forked Java Virtual Machine will be
|
|
|
|
the same as those of the Java VM running Ant. Default is
|
|
|
|
"false" (ignored if fork is disabled).
|
|
|
|
<em>since Ant 1.7</em></td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
2000-08-09 13:12:13 +00:00
|
|
|
</table>
|
|
|
|
|
2002-03-20 00:02:15 +00:00
|
|
|
<p>By using the <code>errorproperty</code> and <code>failureproperty</code>
|
|
|
|
attributes, it is possible to
|
|
|
|
perform setup work (such as starting an external server), execute the test,
|
|
|
|
clean up, and still fail the build in the event of a failure.</p>
|
|
|
|
|
|
|
|
<p>The <code>filtertrace</code> attribute condenses error and failure
|
|
|
|
stack traces before reporting them.
|
|
|
|
It works with both the plain and XML formatters. It filters out any lines
|
|
|
|
that begin with the following string patterns:<pre>
|
|
|
|
"junit.framework.TestCase"
|
|
|
|
"junit.framework.TestResult"
|
|
|
|
"junit.framework.TestSuite"
|
|
|
|
"junit.framework.Assert."
|
|
|
|
"junit.swingui.TestRunner"
|
|
|
|
"junit.awtui.TestRunner"
|
|
|
|
"junit.textui.TestRunner"
|
|
|
|
"java.lang.reflect.Method.invoke("
|
|
|
|
"org.apache.tools.ant."</pre></p>
|
|
|
|
|
2000-08-09 13:12:13 +00:00
|
|
|
<h3><a name="nested">Nested Elements</a></h3>
|
|
|
|
|
2002-03-20 00:02:15 +00:00
|
|
|
<p>The <code><junit></code> task
|
|
|
|
supports a nested <code><classpath></code>
|
|
|
|
element that represents a <a href="../using.html#path">PATH like
|
2000-10-05 09:12:07 +00:00
|
|
|
structure</a>.</p>
|
2000-08-09 13:12:13 +00:00
|
|
|
|
|
|
|
<h4>jvmarg</h4>
|
|
|
|
|
2002-03-20 00:02:15 +00:00
|
|
|
<p>If <code>fork</code> is enabled, additional parameters may be passed to
|
|
|
|
the new VM via nested <code><jvmarg></code> elements. For example:</p>
|
2000-08-09 13:12:13 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<pre>
|
2000-08-09 13:12:13 +00:00
|
|
|
<junit fork="yes">
|
|
|
|
<jvmarg value="-Djava.compiler=NONE"/>
|
2001-01-30 17:01:39 +00:00
|
|
|
...
|
2000-08-09 13:12:13 +00:00
|
|
|
</junit>
|
2001-02-13 12:32:01 +00:00
|
|
|
</pre>
|
|
|
|
|
2001-09-08 01:05:18 +00:00
|
|
|
<p>would run the test in a VM without JIT.</p>
|
2000-08-09 13:12:13 +00:00
|
|
|
|
2000-08-09 15:50:23 +00:00
|
|
|
<p><code><jvmarg></code> allows all attributes described in <a
|
2002-03-20 00:02:15 +00:00
|
|
|
href="../using.html#arg">Command-line Arguments</a>.</p>
|
2000-08-09 13:12:13 +00:00
|
|
|
|
2001-01-30 17:01:39 +00:00
|
|
|
<h4>sysproperty</h4>
|
|
|
|
|
|
|
|
<p>Use nested <code><sysproperty></code> elements to specify system
|
|
|
|
properties required by the class. These properties will be made available
|
2002-03-20 00:02:15 +00:00
|
|
|
to the VM during the execution of the test (either ANT's VM or the forked VM,
|
|
|
|
if <code>fork</code> is enabled).
|
2001-09-08 01:05:18 +00:00
|
|
|
The attributes for this element are the same as for <a href="../CoreTasks/exec.html#env">environment variables</a>.</p>
|
2001-01-30 17:01:39 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<pre>
|
2001-01-30 17:01:39 +00:00
|
|
|
<junit fork="no">
|
|
|
|
<sysproperty key="basedir" value="${basedir}"/>
|
|
|
|
...
|
|
|
|
</junit>
|
2001-02-13 12:32:01 +00:00
|
|
|
</pre>
|
|
|
|
|
2001-09-08 01:05:18 +00:00
|
|
|
<p>would run the test in ANT's VM and make the <code>basedir</code> property
|
2001-01-30 17:01:39 +00:00
|
|
|
available to the test.</p>
|
|
|
|
|
2003-05-12 15:19:18 +00:00
|
|
|
<h4>syspropertyset</h4>
|
|
|
|
|
|
|
|
<p>You can specify a set of properties to be used as system properties
|
|
|
|
with <a href="../CoreTypes/propertyset.html">syspropertyset</a>s.</p>
|
|
|
|
|
|
|
|
<p><em>since Ant 1.6</em>.</p>
|
2001-01-30 17:01:39 +00:00
|
|
|
|
2002-03-14 01:01:18 +00:00
|
|
|
<h4>env</h4>
|
2002-01-29 16:35:46 +00:00
|
|
|
|
|
|
|
<p>It is possible to specify environment variables to pass to the
|
2002-03-20 00:02:15 +00:00
|
|
|
forked VM via nested <code><env></code> elements. For a description
|
|
|
|
of the <code><env></code> element's attributes, see the
|
|
|
|
description in the <a href="../CoreTasks/exec.html#env">exec</a> task.</p>
|
2002-01-29 16:35:46 +00:00
|
|
|
|
2002-03-20 00:02:15 +00:00
|
|
|
<p>Settings will be ignored if <code>fork</code> is disabled.</p>
|
2002-01-29 16:35:46 +00:00
|
|
|
|
2003-05-27 08:49:42 +00:00
|
|
|
<h4>bootclasspath</h4>
|
|
|
|
|
|
|
|
<p>The location of bootstrap class files can be specified using this
|
|
|
|
<a href="../using.html#path">PATH like structure</a> - will be ignored
|
|
|
|
if <i>fork</i> is not <code>true</code> or the target VM doesn't
|
|
|
|
support it (i.e. Java 1.1).</p>
|
|
|
|
|
|
|
|
<p><em>since Ant 1.6</em>.</p>
|
|
|
|
|
2003-08-27 14:23:17 +00:00
|
|
|
<h4>permissions</h4>
|
|
|
|
<p>Security permissions can be revoked and granted during the execution of the
|
|
|
|
class via a nested <i>permissions</i> element. For more information please
|
|
|
|
see <a href="../CoreTypes/permissions.html">permissions</a></p>
|
|
|
|
|
|
|
|
<p>Settings will be ignored if fork is enabled.</p>
|
|
|
|
|
|
|
|
<p><em>since Ant 1.6</em>.</p>
|
|
|
|
|
2004-02-02 14:33:08 +00:00
|
|
|
<h4>assertions</h4>
|
|
|
|
|
|
|
|
<p>You can control enablement of Java 1.4 assertions with an
|
|
|
|
<a href="../CoreTypes/assertions.html"><tt><assertions></tt></a>
|
|
|
|
subelement.</p>
|
|
|
|
|
|
|
|
<p><em>since Ant 1.6.</em></p>
|
|
|
|
|
2000-08-09 13:12:13 +00:00
|
|
|
<h4>formatter</h4>
|
|
|
|
|
|
|
|
<p>The results of the tests can be printed in different
|
2002-03-20 00:02:15 +00:00
|
|
|
formats. Output will always be sent to a file, unless you set the
|
|
|
|
<code>usefile</code> attribute to <code>false</code>.
|
|
|
|
The name of the file is determined by the
|
2000-09-14 08:13:06 +00:00
|
|
|
name of the test and can be set by the <code>outfile</code> attribute
|
2001-09-08 01:05:18 +00:00
|
|
|
of <code><test></code>.</p>
|
2000-08-09 13:12:13 +00:00
|
|
|
|
2002-03-20 00:02:15 +00:00
|
|
|
<p>There are three predefined formatters - one prints the test results
|
|
|
|
in XML format, the other emits plain text. The formatter named
|
|
|
|
<code>brief</code> will only print detailed information for testcases
|
|
|
|
that failed, while <code>plain</code> gives a little statistics line
|
2001-05-04 08:03:53 +00:00
|
|
|
for all test cases. Custom formatters that need to implement
|
2000-08-09 13:12:13 +00:00
|
|
|
<code>org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter</code>
|
|
|
|
can be specified.</p>
|
|
|
|
|
2002-04-09 12:13:25 +00:00
|
|
|
<p>If you use the XML formatter, it may not include the same output
|
|
|
|
that your tests have written as some characters are illegal in XML
|
|
|
|
documents and will be dropped.</p>
|
|
|
|
|
2000-08-09 13:12:13 +00:00
|
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<td width="12%" valign="top"><b>Attribute</b></td>
|
|
|
|
<td width="78%" valign="top"><b>Description</b></td>
|
|
|
|
<td width="10%" valign="top"><b>Required</b></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">type</td>
|
2001-05-04 08:03:53 +00:00
|
|
|
<td valign="top">Use a predefined formatter (either
|
2002-03-20 00:02:15 +00:00
|
|
|
<code>xml</code>, <code>plain</code>, or <code>brief</code>).</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
<td align="center" rowspan="2">Exactly one of these.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">classname</td>
|
2000-08-09 15:50:23 +00:00
|
|
|
<td valign="top">Name of a custom formatter class.</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">extension</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
<td valign="top">Extension to append to the output filename.</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td align="center">Yes, if <code>classname</code> has been used.</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
</tr>
|
2000-09-14 08:13:06 +00:00
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">usefile</td>
|
2000-09-14 08:13:06 +00:00
|
|
|
<td valign="top">Boolean that determines whether output should be
|
|
|
|
sent to a file.</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td align="center">No; default is <code>true</code>.</td>
|
2000-09-14 08:13:06 +00:00
|
|
|
</tr>
|
2003-05-28 13:12:03 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top">if</td>
|
|
|
|
<td valign="top">Only use formatter if the named property is set.</td>
|
|
|
|
<td align="center">No; default is <code>true</code>.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top">unless</td>
|
|
|
|
<td valign="top">Only use formatter if the named property is <b>not</b> set.</td>
|
|
|
|
<td align="center">No; default is <code>true</code>.</td>
|
|
|
|
</tr>
|
2000-08-09 13:12:13 +00:00
|
|
|
</table>
|
|
|
|
|
|
|
|
<h4>test</h4>
|
|
|
|
|
|
|
|
<p>Defines a single test class.</p>
|
|
|
|
|
|
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<td width="12%" valign="top"><b>Attribute</b></td>
|
|
|
|
<td width="78%" valign="top"><b>Description</b></td>
|
|
|
|
<td width="10%" valign="top"><b>Required</b></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">name</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">Name of the test class.</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
<td align="center">Yes</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">fork</td>
|
|
|
|
<td valign="top">Run the tests in a separate VM.
|
2000-08-09 13:12:13 +00:00
|
|
|
Overrides value set in <code><junit></code>.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">haltonerror</td>
|
2000-08-09 15:50:23 +00:00
|
|
|
<td valign="top">Stop the build process if an error occurs during the test
|
2000-08-09 13:12:13 +00:00
|
|
|
run. Overrides value set in <code><junit></code>.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
2001-07-17 13:09:48 +00:00
|
|
|
<tr>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">errorproperty</td>
|
2001-07-17 13:09:48 +00:00
|
|
|
<td valign="top">The name of a property to set in the event of an error.
|
2002-03-20 00:02:15 +00:00
|
|
|
Overrides value set in <code><junit></code>.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
2001-07-17 13:09:48 +00:00
|
|
|
</tr>
|
2000-08-09 13:12:13 +00:00
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">haltonfailure</td>
|
|
|
|
<td valign="top">Stop the build process if a test fails (errors are
|
|
|
|
considered failures as well). Overrides value set in
|
2000-08-09 13:12:13 +00:00
|
|
|
<code><junit></code>.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
2001-07-17 13:09:48 +00:00
|
|
|
<tr>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">failureproperty</td>
|
2001-07-17 13:09:48 +00:00
|
|
|
<td valign="top">The name of a property to set in the event of a failure
|
2002-03-20 00:02:15 +00:00
|
|
|
(errors are considered failures as well). Overrides value set in
|
|
|
|
<code><junit></code>.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
2001-07-17 13:09:48 +00:00
|
|
|
</tr>
|
2001-12-09 13:40:18 +00:00
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">filtertrace</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">Filter out Junit and Ant stack frames from error and failure stack
|
|
|
|
traces. Overrides value set in <code><junit></code>.</td>
|
|
|
|
<td align="center" valign="top">No; default is <code>on</code>.</td>
|
2001-12-09 13:40:18 +00:00
|
|
|
</tr>
|
2000-12-19 12:07:58 +00:00
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">todir</td>
|
2000-12-19 12:07:58 +00:00
|
|
|
<td valign="top">Directory to write the reports to.</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td align="center" valign="top">No; default is the current directory.</td>
|
2000-12-19 12:07:58 +00:00
|
|
|
</tr>
|
2000-08-09 13:12:13 +00:00
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">outfile</td>
|
2000-08-09 15:50:23 +00:00
|
|
|
<td valign="top">Base name of the test result. The full filename is
|
2000-08-09 13:12:13 +00:00
|
|
|
determined by this attribute and the extension of
|
|
|
|
<code>formatter</code>.</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td align="center" valign="top">No; default is
|
|
|
|
<code>TEST-</code><em>name</em>, where <em>name</em> is the name of
|
|
|
|
the test specified in the <code>name</code> attribute.</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">if</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
<td valign="top">Only run test if the named property is set.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">unless</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
<td valign="top">Only run test if the named property is <b>not</b> set.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<p>Tests can define their own formatters via nested
|
|
|
|
<code><formatter></code> elements.</p>
|
|
|
|
|
|
|
|
<h4>batchtest</h4>
|
|
|
|
|
|
|
|
<p>Define a number of tests based on pattern matching.</p>
|
|
|
|
|
|
|
|
<p><code>batchtest</code> collects the included files from any number
|
2000-08-10 11:23:02 +00:00
|
|
|
of nested <a
|
2001-02-13 12:32:01 +00:00
|
|
|
href="../CoreTypes/fileset.html"><code><fileset></code></a>s. It then
|
2000-09-07 09:51:02 +00:00
|
|
|
generates a test class name for each file that ends in
|
|
|
|
<code>.java</code> or <code>.class</code>.</p>
|
2000-08-09 13:12:13 +00:00
|
|
|
|
|
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
|
|
<tr>
|
|
|
|
<td width="12%" valign="top"><b>Attribute</b></td>
|
|
|
|
<td width="78%" valign="top"><b>Description</b></td>
|
|
|
|
<td width="10%" valign="top"><b>Required</b></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">fork</td>
|
|
|
|
<td valign="top">Run the tests in a separate VM.
|
2000-08-09 13:12:13 +00:00
|
|
|
Overrides value set in <code><junit></code>.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">haltonerror</td>
|
2000-08-09 15:50:23 +00:00
|
|
|
<td valign="top">Stop the build process if an error occurs during the test
|
2000-08-09 13:12:13 +00:00
|
|
|
run. Overrides value set in <code><junit></code>.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
2001-07-17 13:09:48 +00:00
|
|
|
<tr>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">errorproperty</td>
|
2001-07-17 13:09:48 +00:00
|
|
|
<td valign="top">The name of a property to set in the event of an error.
|
2002-03-20 00:02:15 +00:00
|
|
|
Overrides value set in <code><junit></code>.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
2001-07-17 13:09:48 +00:00
|
|
|
</tr>
|
2000-08-09 13:12:13 +00:00
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">haltonfailure</td>
|
|
|
|
<td valign="top">Stop the build process if a test fails (errors are
|
|
|
|
considered failures as well). Overrides value set in
|
2000-08-09 13:12:13 +00:00
|
|
|
<code><junit></code>.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
2001-07-17 13:09:48 +00:00
|
|
|
<tr>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">failureproperty</td>
|
2001-07-17 13:09:48 +00:00
|
|
|
<td valign="top">The name of a property to set in the event of a failure
|
2002-03-20 00:02:15 +00:00
|
|
|
(errors are considered failures as well). Overrides value set in
|
|
|
|
<code><junit></code></td>
|
|
|
|
<td align="center" valign="top">No</td>
|
2001-07-17 13:09:48 +00:00
|
|
|
</tr>
|
2001-12-09 13:40:18 +00:00
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">filtertrace</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">Filter out Junit and Ant stack frames from error and failure stack
|
|
|
|
traces. Overrides value set in <code><junit></code>.</td>
|
|
|
|
<td align="center" valign="top">No; default is <code>on</code>.</td>
|
2001-12-09 13:40:18 +00:00
|
|
|
</tr>
|
2000-12-19 12:07:58 +00:00
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">todir</td>
|
2000-12-19 12:07:58 +00:00
|
|
|
<td valign="top">Directory to write the reports to.</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td align="center" valign="top">No; default is the current directory.</td>
|
2000-12-19 12:07:58 +00:00
|
|
|
</tr>
|
2000-08-09 13:12:13 +00:00
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">if</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
<td valign="top">Only run tests if the named property is set.</td>
|
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2002-03-14 01:01:18 +00:00
|
|
|
<td valign="top">unless</td>
|
2002-03-20 00:02:15 +00:00
|
|
|
<td valign="top">Only run tests if the named property is <strong>not</strong> set.</td>
|
2000-08-09 13:12:13 +00:00
|
|
|
<td align="center" valign="top">No</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<p>Batchtests can define their own formatters via nested
|
|
|
|
<code><formatter></code> elements.</p>
|
|
|
|
|
|
|
|
<h3>Examples</h3>
|
2001-02-13 12:32:01 +00:00
|
|
|
|
2001-09-08 01:05:18 +00:00
|
|
|
<pre>
|
2000-08-09 13:12:13 +00:00
|
|
|
<junit>
|
2002-09-04 11:05:19 +00:00
|
|
|
<test name="my.test.TestCase"/>
|
2000-08-09 13:12:13 +00:00
|
|
|
</junit>
|
2001-02-13 12:32:01 +00:00
|
|
|
</pre>
|
2000-08-09 13:12:13 +00:00
|
|
|
|
2001-09-08 01:05:18 +00:00
|
|
|
<p>Runs the test defined in <code>my.test.TestCase</code> in the same
|
2000-08-09 13:12:13 +00:00
|
|
|
VM. No output will be generated unless the test fails.</p>
|
|
|
|
|
2001-09-08 01:05:18 +00:00
|
|
|
<pre>
|
2000-08-09 13:12:13 +00:00
|
|
|
<junit printsummary="yes" fork="yes" haltonfailure="yes">
|
2002-09-04 11:05:19 +00:00
|
|
|
<formatter type="plain"/>
|
|
|
|
<test name="my.test.TestCase"/>
|
2000-08-09 13:12:13 +00:00
|
|
|
</junit>
|
2001-02-13 12:32:01 +00:00
|
|
|
</pre>
|
2000-08-09 13:12:13 +00:00
|
|
|
|
2001-09-08 01:05:18 +00:00
|
|
|
<p>Runs the test defined in <code>my.test.TestCase</code> in a
|
2002-03-20 00:02:15 +00:00
|
|
|
separate VM. At the end of the test, a one-line summary will be
|
2000-08-09 13:12:13 +00:00
|
|
|
printed. A detailed report of the test can be found in
|
|
|
|
<code>TEST-my.test.TestCase.txt</code>. The build process will be
|
|
|
|
stopped if the test fails.</p>
|
|
|
|
|
2001-09-08 01:05:18 +00:00
|
|
|
<pre>
|
2000-08-09 13:12:13 +00:00
|
|
|
<junit printsummary="yes" haltonfailure="yes">
|
|
|
|
<classpath>
|
2002-09-04 11:05:19 +00:00
|
|
|
<pathelement location="${build.tests}"/>
|
|
|
|
<pathelement path="${java.class.path}"/>
|
2000-08-09 13:12:13 +00:00
|
|
|
</classpath>
|
|
|
|
|
2002-09-04 11:05:19 +00:00
|
|
|
<formatter type="plain"/>
|
2000-08-09 13:12:13 +00:00
|
|
|
|
2002-09-04 11:05:19 +00:00
|
|
|
<test name="my.test.TestCase" haltonfailure="no" outfile="result">
|
|
|
|
<formatter type="xml"/>
|
2000-08-09 13:12:13 +00:00
|
|
|
</test>
|
|
|
|
|
2000-12-19 12:07:58 +00:00
|
|
|
<batchtest fork="yes" todir="${reports.tests}">
|
2000-08-09 13:12:13 +00:00
|
|
|
<fileset dir="${src.tests}">
|
2002-09-04 11:05:19 +00:00
|
|
|
<include name="**/*Test*.java"/>
|
|
|
|
<exclude name="**/AllTests.java"/>
|
2000-08-09 13:12:13 +00:00
|
|
|
</fileset>
|
|
|
|
</batchtest>
|
|
|
|
</junit>
|
2001-02-13 12:32:01 +00:00
|
|
|
</pre>
|
2000-08-09 13:12:13 +00:00
|
|
|
|
2002-03-20 00:02:15 +00:00
|
|
|
<p>Runs <code>my.test.TestCase</code> in the same VM, ignoring the
|
|
|
|
given CLASSPATH; only a warning is printed if this test fails. In
|
2000-08-09 15:50:23 +00:00
|
|
|
addition to the plain text test results, for this test a XML result
|
2002-03-20 00:02:15 +00:00
|
|
|
will be output to <code>result.xml</code>.
|
|
|
|
Then, for each matching file in the directory defined for
|
|
|
|
<code>${src.tests}</code> a
|
2000-08-09 13:12:13 +00:00
|
|
|
test is run in a separate VM. If a test fails, the build process is
|
|
|
|
aborted. Results are collected in files named
|
2002-03-20 00:02:15 +00:00
|
|
|
<code>TEST-</code><em>name</em><code>.txt</code> and written to
|
|
|
|
<code>${reports.tests}</code>.</p>
|
2000-08-09 13:12:13 +00:00
|
|
|
|
2002-01-10 08:48:33 +00:00
|
|
|
<hr>
|
2004-02-09 21:50:10 +00:00
|
|
|
<p align="center">Copyright © 2000-2004 The Apache Software Foundation. All rights
|
2002-01-10 08:48:33 +00:00
|
|
|
Reserved.</p>
|
2000-08-09 13:12:13 +00:00
|
|
|
</body>
|
|
|
|
</html>
|