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

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