You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

junit.html 21 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <html>
  2. <head>
  3. <title>JUnit Task</title>
  4. </head>
  5. <body>
  6. <h2><a name="junit">JUnit</a></h2>
  7. <h3>Description</h3>
  8. <p>This task runs tests from the JUnit testing framework. The latest
  9. version of the framework can be found at
  10. <a href="http://www.junit.org">http://www.junit.org</a>.
  11. This task has been tested with JUnit 3.0 up to JUnit 3.8.1; it won't
  12. work with versions prior to JUnit 3.0.</p>
  13. <p><strong>Note:</strong> This task depends on external libraries not included
  14. in the Ant distribution. See <a href="../install.html#librarydependencies">
  15. Library Dependencies</a> for more information.
  16. </p>
  17. <p>
  18. <strong>Note</strong>:
  19. You must have <code>junit.jar</code> and the class files for the
  20. <code>&lt;junit&gt;</code> task in the same classpath.
  21. You can do one of:
  22. <ol>
  23. <li>
  24. Put both <code>junit.jar</code> and the optional tasks jar file in
  25. <code>ANT_HOME/lib</code>.
  26. </li>
  27. <li>
  28. Do not put either in <code>ANT_HOME/lib</code>, and instead
  29. include their locations in your <code>CLASSPATH</code> environment variable.
  30. </li>
  31. <li>
  32. Do neither of the above, and instead, specify their locations using
  33. a <code>&lt;classpath&gt;</code> element in the build file.
  34. See <a href="../../faq.html#delegating-classloader" target="_top">the
  35. FAQ</a> for details.
  36. </ol>
  37. </p>
  38. <p>Tests are defined by nested <code>test</code> or
  39. <code>batchtest</code> tags (see <a href="#nested">nested
  40. elements</a>).</p>
  41. <h3>Parameters</h3>
  42. <table border="1" cellpadding="2" cellspacing="0">
  43. <tr>
  44. <td width="12%" valign="top"><b>Attribute</b></td>
  45. <td width="78%" valign="top"><b>Description</b></td>
  46. <td width="10%" valign="top"><b>Required</b></td>
  47. </tr>
  48. <tr>
  49. <td valign="top">printsummary</td>
  50. <td valign="top">Print one-line statistics for each testcase. Can
  51. take the values <code>on</code>,
  52. <code>off</code>, and
  53. <code>withOutAndErr</code>.
  54. <code>withOutAndErr</code> is the same
  55. as <code>on</code> but also includes the output of the test
  56. as written to <code>System.out</code> and <code>System.err</code>.</td>
  57. <td align="center" valign="top">No; default is <code>off</code>.</td>
  58. </tr>
  59. <tr>
  60. <td valign="top">fork</td>
  61. <td valign="top">Run the tests in a separate VM.</td>
  62. <td align="center" valign="top">No; default is <code>off</code>.</td>
  63. </tr>
  64. <tr>
  65. <td valign="top">forkmode</td>
  66. <td valign="top">Controls how many Java Virtual Machines get
  67. created if you want to fork some tests. Possible values are
  68. &quot;perTest&quot; (the default), &quot;perBatch&quot; and
  69. &quot;once&quot;. &quot;once&quot; creates only a single Java VM
  70. for all tests while &quot;perTest&quot; creates a new VM for each
  71. TestCase class. &quot;perBatch&quot; creates a VM for each nested
  72. <code>&lt;batchtest&gt;</code> and one collecting all nested
  73. <code>&lt;test&gt;</code>s. Note that only tests with the same
  74. settings of <code>filtertrace</code>, <code>haltonerror</code>,
  75. <code>haltonfailure</code>, <code>errorproperty</code> and
  76. <code>failureproperty</code> can share a VM, so even if you set
  77. <code>forkmode</code> to &quot;once&quot;, Ant may have to create
  78. more than a single Java VM. This attribute is ignored for tests
  79. that don't get forked into a new Java VM. <em>since Ant 1.6.2</em></td>
  80. <td align="center" valign="top">No; default is <code>perTest</code>.</td>
  81. </tr>
  82. <tr>
  83. <td valign="top">haltonerror</td>
  84. <td valign="top">Stop the build process if an error occurs during the test
  85. run.</td>
  86. <td align="center" valign="top">No; default is <code>off</code>.</td>
  87. </tr>
  88. <tr>
  89. <td valign="top">errorproperty</td>
  90. <td valign="top">The name of a property to set in the event of an error.</td>
  91. <td align="center" valign="top">No</td>
  92. </tr>
  93. <tr>
  94. <td valign="top">haltonfailure</td>
  95. <td valign="top">Stop the build process if a test fails (errors are
  96. considered failures as well).</td>
  97. <td align="center" valign="top">No; default is <code>off</code>.</td>
  98. </tr>
  99. <tr>
  100. <td valign="top">failureproperty</td>
  101. <td valign="top">The name of a property to set in the event of a failure
  102. (errors are considered failures as well).</td>
  103. <td align="center" valign="top">No.</td>
  104. </tr>
  105. <tr>
  106. <td valign="top">filtertrace</td>
  107. <td valign="top">Filter out Junit and Ant stack frames from error and failure stack traces.</td>
  108. <td align="center" valign="top">No; default is <code>on</code>.</td>
  109. </tr>
  110. <tr>
  111. <td valign="top">timeout</td>
  112. <td valign="top">Cancel the individual tests if they don't finish
  113. in the given time (measured in milliseconds). Ignored if
  114. <code>fork</code> is disabled.</td>
  115. <td align="center" valign="top">No</td>
  116. </tr>
  117. <tr>
  118. <td valign="top">maxmemory</td>
  119. <td valign="top">Maximum amount of memory to allocate to the forked VM.
  120. Ignored if <code>fork</code> is disabled.</td>
  121. <td align="center" valign="top">No</td>
  122. </tr>
  123. <tr>
  124. <td valign="top">jvm</td>
  125. <td valign="top">The command used to invoke the Java Virtual Machine,
  126. default is 'java'. The command is resolved by
  127. <code>java.lang.Runtime.exec()</code>.
  128. Ignored if <code>fork</code> is disabled.</td>
  129. <td align="center" valign="top">No; default is <code>java</code>.</td>
  130. </tr>
  131. <tr>
  132. <td valign="top">dir</td>
  133. <td valign="top">The directory in which to invoke the VM. Ignored if
  134. <code>fork</code> is disabled.</td>
  135. <td align="center" valign="top">No</td>
  136. </tr>
  137. <tr>
  138. <td valign="top">newenvironment</td>
  139. <td valign="top">Do not propagate the old environment when new
  140. environment variables are specified. Ignored if <code>fork</code> is
  141. disabled.</td>
  142. <td align="center" valign="top">No; default is <code>false</code>.</td>
  143. </tr>
  144. <tr>
  145. <td valign="top">includeantruntime</td>
  146. <td valign="top">Implicitly add the Ant classes required to run
  147. the tests and JUnit to the classpath in forked mode.
  148. <b>Note:</b> Please read the <a
  149. href="../../faq.html#junit-no-runtime-xml">Ant FAQ</a> if you
  150. want to set this to <code>false</code> and use the XML formatter
  151. at the same time.</td>
  152. <td align="center" valign="top">No; default is <code>true</code>.</td>
  153. </tr>
  154. <tr>
  155. <td valign="top">showoutput</td>
  156. <td valign="top">Send any output generated by tests to Ant's
  157. logging system as well as to the formatters. By default only the
  158. formatters receive the output.</td>
  159. <td align="center" valign="top">No</td>
  160. </tr>
  161. <tr>
  162. <td valign="top">tempdir</td>
  163. <td valign="top">Where Ant should place temporary files.
  164. <em>Since Ant 1.6</em>.</td>
  165. <td align="center" valign="top">No; default is the project's base
  166. directory.</td>
  167. </tr>
  168. <tr>
  169. <td valign="top">reloading</td>
  170. <td valign="top">Whether or not a new classloader should be instantiated for each test case.<br/>
  171. Ignore if <code>fork</code> is set to true.
  172. <em>Since Ant 1.6</em>.</td>
  173. <td align="center" valign="top">No; default is <code>true</code>.</td>
  174. </tr>
  175. <tr>
  176. <td valign="top">clonevm</td>
  177. <td valign="top">If set to true true, then all system properties
  178. and the bootclasspath of the forked Java Virtual Machine will be
  179. the same as those of the Java VM running Ant. Default is
  180. &quot;false&quot; (ignored if fork is disabled).
  181. <em>since Ant 1.7</em></td>
  182. <td align="center" valign="top">No</td>
  183. </tr>
  184. </table>
  185. <p>By using the <code>errorproperty</code> and <code>failureproperty</code>
  186. attributes, it is possible to
  187. perform setup work (such as starting an external server), execute the test,
  188. clean up, and still fail the build in the event of a failure.</p>
  189. <p>The <code>filtertrace</code> attribute condenses error and failure
  190. stack traces before reporting them.
  191. It works with both the plain and XML formatters. It filters out any lines
  192. that begin with the following string patterns:<pre>
  193. "junit.framework.TestCase"
  194. "junit.framework.TestResult"
  195. "junit.framework.TestSuite"
  196. "junit.framework.Assert."
  197. "junit.swingui.TestRunner"
  198. "junit.awtui.TestRunner"
  199. "junit.textui.TestRunner"
  200. "java.lang.reflect.Method.invoke("
  201. "org.apache.tools.ant."</pre></p>
  202. <h3><a name="nested">Nested Elements</a></h3>
  203. <p>The <code>&lt;junit&gt;</code> task
  204. supports a nested <code>&lt;classpath&gt;</code>
  205. element that represents a <a href="../using.html#path">PATH like
  206. structure</a>.</p>
  207. <h4>jvmarg</h4>
  208. <p>If <code>fork</code> is enabled, additional parameters may be passed to
  209. the new VM via nested <code>&lt;jvmarg&gt;</code> elements. For example:</p>
  210. <pre>
  211. &lt;junit fork=&quot;yes&quot;&gt;
  212. &lt;jvmarg value=&quot;-Djava.compiler=NONE&quot;/&gt;
  213. ...
  214. &lt;/junit&gt;
  215. </pre>
  216. <p>would run the test in a VM without JIT.</p>
  217. <p><code>&lt;jvmarg&gt;</code> allows all attributes described in <a
  218. href="../using.html#arg">Command-line Arguments</a>.</p>
  219. <h4>sysproperty</h4>
  220. <p>Use nested <code>&lt;sysproperty&gt;</code> elements to specify system
  221. properties required by the class. These properties will be made available
  222. to the VM during the execution of the test (either ANT's VM or the forked VM,
  223. if <code>fork</code> is enabled).
  224. The attributes for this element are the same as for <a href="../CoreTasks/exec.html#env">environment variables</a>.</p>
  225. <pre>
  226. &lt;junit fork=&quot;no&quot;&gt;
  227. &lt;sysproperty key=&quot;basedir&quot; value=&quot;${basedir}&quot;/&gt;
  228. ...
  229. &lt;/junit&gt;
  230. </pre>
  231. <p>would run the test in ANT's VM and make the <code>basedir</code> property
  232. available to the test.</p>
  233. <h4>syspropertyset</h4>
  234. <p>You can specify a set of properties to be used as system properties
  235. with <a href="../CoreTypes/propertyset.html">syspropertyset</a>s.</p>
  236. <p><em>since Ant 1.6</em>.</p>
  237. <h4>env</h4>
  238. <p>It is possible to specify environment variables to pass to the
  239. forked VM via nested <code>&lt;env&gt;</code> elements. For a description
  240. of the <code>&lt;env&gt;</code> element's attributes, see the
  241. description in the <a href="../CoreTasks/exec.html#env">exec</a> task.</p>
  242. <p>Settings will be ignored if <code>fork</code> is disabled.</p>
  243. <h4>bootclasspath</h4>
  244. <p>The location of bootstrap class files can be specified using this
  245. <a href="../using.html#path">PATH like structure</a> - will be ignored
  246. if <i>fork</i> is not <code>true</code> or the target VM doesn't
  247. support it (i.e. Java 1.1).</p>
  248. <p><em>since Ant 1.6</em>.</p>
  249. <h4>permissions</h4>
  250. <p>Security permissions can be revoked and granted during the execution of the
  251. class via a nested <i>permissions</i> element. For more information please
  252. see <a href="../CoreTypes/permissions.html">permissions</a></p>
  253. <p>Settings will be ignored if fork is enabled.</p>
  254. <p><em>since Ant 1.6</em>.</p>
  255. <h4>assertions</h4>
  256. <p>You can control enablement of Java 1.4 assertions with an
  257. <a href="../CoreTypes/assertions.html"><tt>&lt;assertions&gt;</tt></a>
  258. subelement.</p>
  259. <p>Assertion statements are currently ignored in non-forked mode.</p>
  260. <p><em>since Ant 1.6.</em></p>
  261. <h4>formatter</h4>
  262. <p>The results of the tests can be printed in different
  263. formats. Output will always be sent to a file, unless you set the
  264. <code>usefile</code> attribute to <code>false</code>.
  265. The name of the file is determined by the
  266. name of the test and can be set by the <code>outfile</code> attribute
  267. of <code>&lt;test&gt;</code>.</p>
  268. <p>There are three predefined formatters - one prints the test results
  269. in XML format, the other emits plain text. The formatter named
  270. <code>brief</code> will only print detailed information for testcases
  271. that failed, while <code>plain</code> gives a little statistics line
  272. for all test cases. Custom formatters that need to implement
  273. <code>org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter</code>
  274. can be specified.</p>
  275. <p>If you use the XML formatter, it may not include the same output
  276. that your tests have written as some characters are illegal in XML
  277. documents and will be dropped.</p>
  278. <p><b>Note:</b> Please read the <a
  279. href="../../faq.html#junit-no-runtime-xml">Ant FAQ</a> if you want to
  280. set the fork attribute to <code>true</code>, the includeAntRuntime
  281. attribute to <code>false</code> and use the XML formatter at the same
  282. time.</p>
  283. <table border="1" cellpadding="2" cellspacing="0">
  284. <tr>
  285. <td width="12%" valign="top"><b>Attribute</b></td>
  286. <td width="78%" valign="top"><b>Description</b></td>
  287. <td width="10%" valign="top"><b>Required</b></td>
  288. </tr>
  289. <tr>
  290. <td valign="top">type</td>
  291. <td valign="top">Use a predefined formatter (either
  292. <code>xml</code>, <code>plain</code>, or <code>brief</code>).</td>
  293. <td align="center" rowspan="2">Exactly one of these.</td>
  294. </tr>
  295. <tr>
  296. <td valign="top">classname</td>
  297. <td valign="top">Name of a custom formatter class.</td>
  298. </tr>
  299. <tr>
  300. <td valign="top">extension</td>
  301. <td valign="top">Extension to append to the output filename.</td>
  302. <td align="center">Yes, if <code>classname</code> has been used.</td>
  303. </tr>
  304. <tr>
  305. <td valign="top">usefile</td>
  306. <td valign="top">Boolean that determines whether output should be
  307. sent to a file.</td>
  308. <td align="center">No; default is <code>true</code>.</td>
  309. </tr>
  310. <tr>
  311. <td valign="top">if</td>
  312. <td valign="top">Only use formatter if the named property is set.</td>
  313. <td align="center">No; default is <code>true</code>.</td>
  314. </tr>
  315. <tr>
  316. <td valign="top">unless</td>
  317. <td valign="top">Only use formatter if the named property is <b>not</b> set.</td>
  318. <td align="center">No; default is <code>true</code>.</td>
  319. </tr>
  320. </table>
  321. <h4>test</h4>
  322. <p>Defines a single test class.</p>
  323. <table border="1" cellpadding="2" cellspacing="0">
  324. <tr>
  325. <td width="12%" valign="top"><b>Attribute</b></td>
  326. <td width="78%" valign="top"><b>Description</b></td>
  327. <td width="10%" valign="top"><b>Required</b></td>
  328. </tr>
  329. <tr>
  330. <td valign="top">name</td>
  331. <td valign="top">Name of the test class.</td>
  332. <td align="center">Yes</td>
  333. </tr>
  334. <tr>
  335. <td valign="top">fork</td>
  336. <td valign="top">Run the tests in a separate VM.
  337. Overrides value set in <code>&lt;junit&gt;</code>.</td>
  338. <td align="center" valign="top">No</td>
  339. </tr>
  340. <tr>
  341. <td valign="top">haltonerror</td>
  342. <td valign="top">Stop the build process if an error occurs during the test
  343. run. Overrides value set in <code>&lt;junit&gt;</code>.</td>
  344. <td align="center" valign="top">No</td>
  345. </tr>
  346. <tr>
  347. <td valign="top">errorproperty</td>
  348. <td valign="top">The name of a property to set in the event of an error.
  349. Overrides value set in <code>&lt;junit&gt;</code>.</td>
  350. <td align="center" valign="top">No</td>
  351. </tr>
  352. <tr>
  353. <td valign="top">haltonfailure</td>
  354. <td valign="top">Stop the build process if a test fails (errors are
  355. considered failures as well). Overrides value set in
  356. <code>&lt;junit&gt;</code>.</td>
  357. <td align="center" valign="top">No</td>
  358. </tr>
  359. <tr>
  360. <td valign="top">failureproperty</td>
  361. <td valign="top">The name of a property to set in the event of a failure
  362. (errors are considered failures as well). Overrides value set in
  363. <code>&lt;junit&gt;</code>.</td>
  364. <td align="center" valign="top">No</td>
  365. </tr>
  366. <tr>
  367. <td valign="top">filtertrace</td>
  368. <td valign="top">Filter out Junit and Ant stack frames from error and failure stack
  369. traces. Overrides value set in <code>&lt;junit&gt;</code>.</td>
  370. <td align="center" valign="top">No; default is <code>on</code>.</td>
  371. </tr>
  372. <tr>
  373. <td valign="top">todir</td>
  374. <td valign="top">Directory to write the reports to.</td>
  375. <td align="center" valign="top">No; default is the current directory.</td>
  376. </tr>
  377. <tr>
  378. <td valign="top">outfile</td>
  379. <td valign="top">Base name of the test result. The full filename is
  380. determined by this attribute and the extension of
  381. <code>formatter</code>.</td>
  382. <td align="center" valign="top">No; default is
  383. <code>TEST-</code><em>name</em>, where <em>name</em> is the name of
  384. the test specified in the <code>name</code> attribute.</td>
  385. </tr>
  386. <tr>
  387. <td valign="top">if</td>
  388. <td valign="top">Only run test if the named property is set.</td>
  389. <td align="center" valign="top">No</td>
  390. </tr>
  391. <tr>
  392. <td valign="top">unless</td>
  393. <td valign="top">Only run test if the named property is <b>not</b> set.</td>
  394. <td align="center" valign="top">No</td>
  395. </tr>
  396. </table>
  397. <p>Tests can define their own formatters via nested
  398. <code>&lt;formatter&gt;</code> elements.</p>
  399. <h4>batchtest</h4>
  400. <p>Define a number of tests based on pattern matching.</p>
  401. <p><code>batchtest</code> collects the included files from any number
  402. of nested <a
  403. href="../CoreTypes/fileset.html"><code>&lt;fileset&gt;</code></a>s. It then
  404. generates a test class name for each file that ends in
  405. <code>.java</code> or <code>.class</code>.</p>
  406. <table border="1" cellpadding="2" cellspacing="0">
  407. <tr>
  408. <td width="12%" valign="top"><b>Attribute</b></td>
  409. <td width="78%" valign="top"><b>Description</b></td>
  410. <td width="10%" valign="top"><b>Required</b></td>
  411. </tr>
  412. <tr>
  413. <td valign="top">fork</td>
  414. <td valign="top">Run the tests in a separate VM.
  415. Overrides value set in <code>&lt;junit&gt;</code>.</td>
  416. <td align="center" valign="top">No</td>
  417. </tr>
  418. <tr>
  419. <td valign="top">haltonerror</td>
  420. <td valign="top">Stop the build process if an error occurs during the test
  421. run. Overrides value set in <code>&lt;junit&gt;</code>.</td>
  422. <td align="center" valign="top">No</td>
  423. </tr>
  424. <tr>
  425. <td valign="top">errorproperty</td>
  426. <td valign="top">The name of a property to set in the event of an error.
  427. Overrides value set in <code>&lt;junit&gt;</code>.</td>
  428. <td align="center" valign="top">No</td>
  429. </tr>
  430. <tr>
  431. <td valign="top">haltonfailure</td>
  432. <td valign="top">Stop the build process if a test fails (errors are
  433. considered failures as well). Overrides value set in
  434. <code>&lt;junit&gt;</code>.</td>
  435. <td align="center" valign="top">No</td>
  436. </tr>
  437. <tr>
  438. <td valign="top">failureproperty</td>
  439. <td valign="top">The name of a property to set in the event of a failure
  440. (errors are considered failures as well). Overrides value set in
  441. <code>&lt;junit&gt;</code></td>
  442. <td align="center" valign="top">No</td>
  443. </tr>
  444. <tr>
  445. <td valign="top">filtertrace</td>
  446. <td valign="top">Filter out Junit and Ant stack frames from error and failure stack
  447. traces. Overrides value set in <code>&lt;junit&gt;</code>.</td>
  448. <td align="center" valign="top">No; default is <code>on</code>.</td>
  449. </tr>
  450. <tr>
  451. <td valign="top">todir</td>
  452. <td valign="top">Directory to write the reports to.</td>
  453. <td align="center" valign="top">No; default is the current directory.</td>
  454. </tr>
  455. <tr>
  456. <td valign="top">if</td>
  457. <td valign="top">Only run tests if the named property is set.</td>
  458. <td align="center" valign="top">No</td>
  459. </tr>
  460. <tr>
  461. <td valign="top">unless</td>
  462. <td valign="top">Only run tests if the named property is <strong>not</strong> set.</td>
  463. <td align="center" valign="top">No</td>
  464. </tr>
  465. </table>
  466. <p>Batchtests can define their own formatters via nested
  467. <code>&lt;formatter&gt;</code> elements.</p>
  468. <h3>Examples</h3>
  469. <pre>
  470. &lt;junit&gt;
  471. &lt;test name="my.test.TestCase"/&gt;
  472. &lt;/junit&gt;
  473. </pre>
  474. <p>Runs the test defined in <code>my.test.TestCase</code> in the same
  475. VM. No output will be generated unless the test fails.</p>
  476. <pre>
  477. &lt;junit printsummary="yes" fork="yes" haltonfailure="yes"&gt;
  478. &lt;formatter type="plain"/&gt;
  479. &lt;test name="my.test.TestCase"/&gt;
  480. &lt;/junit&gt;
  481. </pre>
  482. <p>Runs the test defined in <code>my.test.TestCase</code> in a
  483. separate VM. At the end of the test, a one-line summary will be
  484. printed. A detailed report of the test can be found in
  485. <code>TEST-my.test.TestCase.txt</code>. The build process will be
  486. stopped if the test fails.</p>
  487. <pre>
  488. &lt;junit printsummary="yes" haltonfailure="yes"&gt;
  489. &lt;classpath&gt;
  490. &lt;pathelement location="${build.tests}"/&gt;
  491. &lt;pathelement path="${java.class.path}"/&gt;
  492. &lt;/classpath&gt;
  493. &lt;formatter type="plain"/&gt;
  494. &lt;test name="my.test.TestCase" haltonfailure="no" outfile="result"&gt;
  495. &lt;formatter type="xml"/&gt;
  496. &lt;/test&gt;
  497. &lt;batchtest fork="yes" todir="${reports.tests}"&gt;
  498. &lt;fileset dir="${src.tests}"&gt;
  499. &lt;include name="**/*Test*.java"/&gt;
  500. &lt;exclude name="**/AllTests.java"/&gt;
  501. &lt;/fileset&gt;
  502. &lt;/batchtest&gt;
  503. &lt;/junit&gt;
  504. </pre>
  505. <p>Runs <code>my.test.TestCase</code> in the same VM, ignoring the
  506. given CLASSPATH; only a warning is printed if this test fails. In
  507. addition to the plain text test results, for this test a XML result
  508. will be output to <code>result.xml</code>.
  509. Then, for each matching file in the directory defined for
  510. <code>${src.tests}</code> a
  511. test is run in a separate VM. If a test fails, the build process is
  512. aborted. Results are collected in files named
  513. <code>TEST-</code><em>name</em><code>.txt</code> and written to
  514. <code>${reports.tests}</code>.</p>
  515. <hr>
  516. <p align="center">Copyright &copy; 2000-2004 The Apache Software Foundation. All rights
  517. Reserved.</p>
  518. </body>
  519. </html>