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.

junitlauncher.html 23 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  18. <title>JUnitLauncher Task</title>
  19. </head>
  20. <body>
  21. <h2 id="junitlauncher">JUnitLauncher</h2>
  22. <h3>Description</h3>
  23. <p>
  24. This task allows tests to be launched and run using the JUnit 5 framework.
  25. </p>
  26. <p>
  27. JUnit 5 introduced a newer set of APIs to write and launch tests. It also introduced the concept
  28. of test engines. Test engines decide which classes are considered as testcases and how they are
  29. executed. JUnit 5 supports running tests that have been written using JUnit 4 constructs as well
  30. as tests that have been written using JUnit 5 constructs. For more details about JUnit 5
  31. itself, please refer to the JUnit 5 project's documentation
  32. at <a href="https://junit.org/junit5/">https://junit.org/junit5/</a>.
  33. </p>
  34. <p>
  35. The goal of this <code>junitlauncher</code> task is to allow launching the JUnit 5 test launcher
  36. and building the test requests so that the selected tests can then be parsed and executed by the
  37. test engine(s) supported by JUnit 5. This task in itself does <i>not</i> understand what a test
  38. case is nor does it execute the tests itself.
  39. </p>
  40. <p>
  41. <strong>Note</strong>: This task depends on external libraries not included in the Apache Ant
  42. distribution. See <a href="../install.html#librarydependencies">Library Dependencies</a> for
  43. more information.
  44. </p>
  45. <p>
  46. <strong>Note</strong>: You must have the necessary JUnit 5 libraries in the classpath of the
  47. tests. At the time of writing this documentation, the list of JUnit 5 platform libraries that
  48. are necessary to run the tests are:
  49. </p>
  50. <ul id="junit-platform-libraries">
  51. <li>
  52. <samp>junit-platform-commons.jar</samp>
  53. </li>
  54. <li>
  55. <samp>junit-platform-engine.jar</samp>
  56. </li>
  57. <li>
  58. <samp>junit-platform-launcher.jar</samp>
  59. </li>
  60. <li>
  61. <samp>opentest4j.jar</samp>
  62. </li>
  63. </ul>
  64. <p>
  65. Depending on the test engine(s) that you want to use in your tests, you will further need the
  66. following libraries in the classpath
  67. </p>
  68. <p id="junit-vintage-engine-libraries">
  69. For <q>junit-vintage</q> engine:
  70. </p>
  71. <ul>
  72. <li>
  73. <samp>junit-vintage-engine.jar</samp>
  74. </li>
  75. <li>
  76. <samp>junit.jar</samp> (JUnit 4.x version)
  77. </li>
  78. </ul>
  79. <p id="junit-jupiter-engine-libraries">
  80. For <q>junit-jupiter</q> engine:
  81. </p>
  82. <ul>
  83. <li>
  84. <samp>junit-jupiter-api.jar</samp>
  85. </li>
  86. <li>
  87. <samp>junit-jupiter-engine.jar</samp>
  88. </li>
  89. </ul>
  90. <p>
  91. To have these in the test classpath, you can follow <em>either</em> of the following approaches:
  92. </p>
  93. <ul>
  94. <li>Put all these relevant jars along with the <samp>ant-junitlauncher.jar</samp>
  95. in <samp>ANT_HOME/lib</samp> directory</li>
  96. <li>OR Leave <samp>ant-junitlauncher.jar</samp> in the <samp>ANT_HOME/lib</samp> directory and
  97. include all other relevant jars in the classpath by passing them as a <kbd>-lib</kbd>
  98. option, while invoking Ant</li>
  99. <li>OR Use the nested <code>&lt;classpath&gt;</code> element to specify the location of the
  100. test engines. For more details about this approach, please read the
  101. <a href=#test-engine-in-classpath>using classpath element to include test engines</a> section.
  102. </ul>
  103. <p>
  104. Tests are defined by nested elements like <code>test</code>, <code>testclasses</code> tags
  105. (see <a href="#nested">nested elements</a>).
  106. </p>
  107. <h3>Parameters</h3>
  108. <table class="attr">
  109. <tr>
  110. <th scope="col">Attribute</th>
  111. <th scope="col">Description</th>
  112. <th scope="col">Required</th>
  113. </tr>
  114. <tr>
  115. <td>haltOnFailure</td>
  116. <td>A value of <q>true</q> implies that build has to stop if any failure occurs in any of
  117. the tests. JUnit 4+ classifies failures as both assertion failures as well as exceptions
  118. that get thrown during test execution. As such, this task too considers both these cases
  119. as failures and doesn't distinguish one from another.
  120. </td>
  121. <td>No; default is <q>false</q></td>
  122. </tr>
  123. <tr>
  124. <td>failureProperty</td>
  125. <td>The name of a property to set in the event of a failure
  126. (exceptions in tests are considered failures as well).
  127. </td>
  128. <td>No</td>
  129. </tr>
  130. <tr>
  131. <td>printSummary</td>
  132. <td>If the value is set to <code>true</code> then this task, upon completion of the test execution,
  133. prints the summary of the execution to <code>System.out</code>. The summary itself is generated
  134. by the JUnit 5 platform and not by this task.
  135. </td>
  136. <td>No; defaults to <code>false</code></td>
  137. </tr>
  138. </table>
  139. <h3 id="nested">Nested Elements</h3>
  140. <h4>classpath</h4>
  141. <p>
  142. The nested <code>&lt;classpath&gt;</code> element that represents
  143. a <a href="../using.html#path">PATH like structure</a> can be used to configure the task to use
  144. this classpath for finding and running the tests. This classpath will be used for:
  145. </p>
  146. <ul>
  147. <li>Finding the test classes to execute</li>
  148. <li>Finding test engines that run the tests</li>
  149. </ul>
  150. <p>
  151. If the <code>classpath</code> element isn't configured for the task, then the classpath of Ant
  152. itself will be used for finding the test classes.
  153. </p>
  154. <h5 id="test-engine-in-classpath">Using the classpath element to include test engines</h5>
  155. <p>
  156. The <code>&lt;classpath&gt;</code> can be used to include the test engines that you want to be
  157. considered for execution of the tests.
  158. </p>
  159. <p>
  160. <strong>NOTE:</strong> An important aspect to remember is that
  161. whether or not you use this approach, the JUnit 5 platform libraries
  162. <a href="#junit-platform-libraries">listed earlier in this
  163. document</a> and the <code>ant-junitlauncher.jar</code>, <i>shouldn't</i> be part of this classpath
  164. and instead they must be included in Ant runtime's classpath either by placing them
  165. in <code>ANT_HOME/lib</code> or by passing the <code>-lib</code> option.
  166. </p>
  167. <p>
  168. Below is an example of setting up the classpath to include the Jupiter test engine during the
  169. execution of the tests. We assume that the JUnit 5 platform libraries and the
  170. <code>ant-junitlauncher.jar</code> have been setup as explained previously.
  171. <br/>
  172. <pre>
  173. &lt;project&gt;
  174. &lt;property name="output.dir" value="${basedir}/build"/&gt;
  175. &lt;property name="src.test.dir" value="${basedir}/src/test"/&gt;
  176. &lt;property name="build.classes.dir" value="${output.dir}/classes"/&gt;
  177. &lt;target name="init"&gt;
  178. &lt;mkdir dir="${output.dir}"/&gt;
  179. &lt;/target&gt;
  180. &lt;path id="junit.engine.jupiter.classpath"&gt;
  181. &lt;fileset dir="${basedir}/src/lib/jupiter/"/&gt;
  182. &lt;/path&gt;
  183. &lt;target name="compile-test" depends="init"&gt;
  184. &lt;mkdir dir="${build.classes.dir}"/&gt;
  185. &lt;javac srcdir="${src.test.dir}"
  186. destdir="${build.classes.dir}"&gt;
  187. &lt;classpath refid="junit.engine.jupiter.classpath"/&gt;
  188. &lt;/javac&gt;
  189. &lt;/target&gt;
  190. &lt;target name="test" depends="compile-test"&gt;
  191. &lt;junitlauncher&gt;
  192. &lt;classpath refid="junit.engine.jupiter.classpath"/&gt;
  193. &lt;classpath&gt;
  194. &lt;pathelement location="${build.classes.dir}"/&gt;
  195. &lt;/classpath&gt;
  196. &lt;testclasses outputdir="${output.dir}"&gt;
  197. &lt;fileset dir="${build.classes.dir}"/&gt;
  198. &lt;listener type="legacy-brief" sendSysOut="true"/&gt;
  199. &lt;listener type="legacy-xml" sendSysErr="true" sendSysOut="true"/&gt;
  200. &lt;/testclasses&gt;
  201. &lt;/junitlauncher&gt;
  202. &lt;/target&gt;
  203. &lt;/project&gt;
  204. </pre>
  205. In the example above, the <code>src/lib/jupiter</code> directory is expected to contain
  206. the Jupiter test engine related jars (which have been
  207. <a href="#junit-jupiter-engine-libraries">listed in an earlier section of this
  208. document</a>). In the <code>test</code> target we use the <code>classpath</code> nested element
  209. to point to the <code>junit.engine.jupiter.classpath</code> containing those jars. In this
  210. <code>test</code> target we also use another <code>classpath</code> element to point to
  211. the location containing our test classes. If required, both these classpath can be combined
  212. into one.
  213. </p>
  214. <h4>listener</h4>
  215. <p>
  216. The <code>junitlauncher</code> task can be configured with <code>listener</code>(s) to listen to
  217. test execution events (such as a test execution starting, completing etc...). The listener is
  218. expected to be a class which implements
  219. the <code class="code">org.junit.platform.launcher.TestExecutionListener</code>.
  220. This <code class="code">TestExecutionListener</code> interface is an API exposed by the JUnit 5
  221. platform APIs and isn't specific to Ant. As such, you can use any existing implementation
  222. of <code class="code">TestExecutionListener</code> in this task.
  223. </p>
  224. <h5>Test result formatter</h5>
  225. <p>
  226. <code>junitlauncher</code> provides a way where the test execution results can be formatted and
  227. presented in a way that's customizable. The task allows for configuring test result formatters,
  228. through the use of <code>listener</code> element. As noted previously, the <code>listener</code>
  229. element expects the listener to implement
  230. the <code class="code">org.junit.platform.launcher.TestExecutionListener</code>
  231. interface. Typically, result formatters need a bit more configuration details to be fed to them,
  232. during the test execution&mdash;details like where to write out the formatted result. Any such
  233. listener can optionally implement
  234. the <code class="code">org.apache.tools.ant.taskdefs.optional.junitlauncher.TestResultFormatter</code>
  235. interface. This interface is specific to Ant <code>junitlauncher</code> task and it extends
  236. the <code class="code">org.junit.platform.launcher.TestExecutionListener</code> interface
  237. </p>
  238. <p>
  239. The <code>junitlauncher</code> task comes with the following pre-defined test result formatter
  240. types:
  241. </p>
  242. <ul>
  243. <li>
  244. <q>legacy-plain</q> : This formatter prints a short statistics line for all test
  245. cases.
  246. </li>
  247. <li>
  248. <q>legacy-brief</q> : This formatter prints information for tests that failed or were
  249. skipped.
  250. </li>
  251. <li>
  252. <q>legacy-xml</q> : This formatter prints statistics for the tests in XML format.
  253. </li>
  254. </ul>
  255. <p>
  256. <strong>Note</strong>: Each of these formatters named <q>legacy</q> try to format the results
  257. similar to what the <code>junit</code> task's formatters used to do. Furthermore,
  258. the <q>legacy-xml</q> formatter generates the XML to comply with the same schema that
  259. the <code>junit</code> task's XML formatter used to follow. As a result, the XML generated by
  260. this formatter, can be used as-is by the <code>junitreport</code> task.
  261. </p>
  262. <p>
  263. The <code>listener</code> element supports the following attributes:
  264. </p>
  265. <table class="attr">
  266. <tr>
  267. <th scope="col">Attribute</th>
  268. <th scope="col">Description</th>
  269. <th scope="col">Required</th>
  270. </tr>
  271. <tr>
  272. <td>type</td>
  273. <td>Use a predefined formatter (either <q>legacy-xml</q>, <q>legacy-plain</q>
  274. or <q>legacy-brief</q>).</td>
  275. <td rowspan="2">Exactly one of these</td>
  276. </tr>
  277. <tr>
  278. <td>classname</td>
  279. <td class="left">Name of a listener class which
  280. implements <code>org.junit.platform.launcher.TestExecutionListener</code> or
  281. the <code>org.apache.tools.ant.taskdefs.optional.junitlauncher.TestResultFormatter</code>
  282. interface
  283. </td>
  284. </tr>
  285. <tr>
  286. <td>resultFile</td>
  287. <td>
  288. The file name to which the formatted result needs to be written to. This attribute is
  289. only relevant when the listener class implements
  290. the <code>org.apache.tools.ant.taskdefs.optional.junitlauncher.TestResultFormatter</code>
  291. interface.
  292. <p>
  293. If no value is specified for this attribute and the listener implements
  294. the <code>org.apache.tools.ant.taskdefs.optional.junitlauncher.TestResultFormatter</code>
  295. then the file name will be defaulted to and will be of the
  296. form <code>TEST-<i>testname</i>.<i>formatter-specific-extension</i></code>
  297. (ex: <samp>TEST-org.myapp.SomeTest.xml</samp> for the <q>legacy-xml</q> type
  298. formatter)
  299. </p>
  300. </td>
  301. <td>No</td>
  302. </tr>
  303. <tr>
  304. <td>sendSysOut</td>
  305. <td>If set to <q>true</q> then the listener will be passed the <code>stdout</code> content
  306. generated by the test(s). This attribute is relevant only if the listener class
  307. implements
  308. the <code>org.apache.tools.ant.taskdefs.optional.junitlauncher.TestResultFormatter</code>
  309. interface.</td>
  310. <td>No; defaults to <q>false</q></td>
  311. </tr>
  312. <tr>
  313. <td>sendSysErr</td>
  314. <td>If set to <q>true</q> then the listener will be passed the <code>stderr</code> content
  315. generated by the test(s). This attribute is relevant only if the listener class
  316. implements
  317. the <code>org.apache.tools.ant.taskdefs.optional.junitlauncher.TestResultFormatter</code>
  318. interface.</td>
  319. <td>No; defaults to <q>false</q></td>
  320. </tr>
  321. <tr>
  322. <td>if</td>
  323. <td>Only use this listener <a href="../properties.html#if+unless">if the named property is
  324. set</a>.</td>
  325. <td>No</td>
  326. </tr>
  327. <tr>
  328. <td>unless</td>
  329. <td>Only use this listener <a href="../properties.html#if+unless">if the named property
  330. is <strong>not</strong> set</a>.</td>
  331. <td>No</td>
  332. </tr>
  333. </table>
  334. <h4>test</h4>
  335. <p>Defines a single test class.</p>
  336. <table class="attr">
  337. <tr>
  338. <th scope="col">Attribute</th>
  339. <th scope="col">Description</th>
  340. <th scope="col">Required</th>
  341. </tr>
  342. <tr>
  343. <td>name</td>
  344. <td>Fully qualified name of the test class.</td>
  345. <td>Yes</td>
  346. </tr>
  347. <tr>
  348. <td>methods</td>
  349. <td>Comma-separated list of names of test case methods to execute. If this is specified,
  350. then only these test methods from the test class will be executed.</td>
  351. <td>No</td>
  352. </tr>
  353. <tr>
  354. <td>haltOnFailure</td>
  355. <td>Stop the build process if a failure occurs during the test run (exceptions are
  356. considered as failures too). Overrides value set on <code>junitlauncher</code>
  357. element.</td>
  358. <td>No</td>
  359. </tr>
  360. <tr>
  361. <td>failureProperty</td>
  362. <td>The name of a property to set in the event of a failure (exceptions are considered
  363. failures as well). Overrides value set on <code>junitlauncher</code> element.</td>
  364. <td>No</td>
  365. </tr>
  366. <tr>
  367. <td>outputDir</td>
  368. <td>Directory to write the reports to.</td>
  369. <td>No; default is the base directory of the project.</td>
  370. </tr>
  371. <tr>
  372. <td>if</td>
  373. <td>Only run this test <a href="../properties.html#if+unless">if the named property is
  374. set</a>.</td>
  375. <td>No</td>
  376. </tr>
  377. <tr>
  378. <td>unless</td>
  379. <td>Only run this test <a href="../properties.html#if+unless">if the named property
  380. is <strong>not</strong> set</a>.</td>
  381. <td>No</td>
  382. </tr>
  383. <tr>
  384. <td>includeEngines</td>
  385. <td>A comma separated set of test engine ids. If specified, only these test engine(s)
  386. will be used for running the tests.
  387. <br/>
  388. For example: <code>includeEngines="junit-jupiter"</code> will only use the Jupiter
  389. test engine for execution of the tests and will ignore any other engines that might
  390. have been found in the classpath.
  391. </td>
  392. <td>No</td>
  393. </tr>
  394. <tr>
  395. <td>excludeEngines</td>
  396. <td>A comma separated set of test engine ids. If specified, these test engine(s)
  397. will be excluded when running the tests.
  398. <br/>
  399. For example: <code>excludeEngines="junit-vintage"</code> will exclude the vintage
  400. test engine during execution of the tests and will use any other engines that might
  401. have been found in the classpath.
  402. </td>
  403. <td>No</td>
  404. </tr>
  405. </table>
  406. <p>
  407. Tests can define their own listeners via nested <code>listener</code> elements.
  408. </p>
  409. <h4>testclasses</h4>
  410. <p>Define a number of tests based on pattern matching.</p>
  411. <p>
  412. <code>testclasses</code> collects the included <a href="../Types/resources.html">resources</a>
  413. from any number of nested <a href="../Types/resources.html#collection">Resource
  414. Collection</a>s. It then selects each resource whose name ends in <code>.class</code>. These
  415. classes are then passed on to the JUnit 5 platform for it to decide and run them as tests.
  416. </p>
  417. <table class="attr">
  418. <tr>
  419. <th scope="col">Attribute</th>
  420. <th scope="col">Description</th>
  421. <th scope="col">Required</th>
  422. </tr>
  423. <tr>
  424. <td>haltOnFailure</td>
  425. <td>Stop the build process if a failure occurs during the test run (exceptions are
  426. considered as failures too). Overrides value set on <code>junitlauncher</code>
  427. element.</td>
  428. <td>No</td>
  429. </tr>
  430. <tr>
  431. <td>failureProperty</td>
  432. <td>The name of a property to set in the event of a failure (exceptions are considered
  433. failures as well). Overrides value set on <code>junitlauncher</code> element.</td>
  434. <td>No</td>
  435. </tr>
  436. <tr>
  437. <td>outputDir</td>
  438. <td>Directory to write the reports to.</td>
  439. <td>No; default is the base directory of the project.</td>
  440. </tr>
  441. <tr>
  442. <td>if</td>
  443. <td>Only run the tests <a href="../properties.html#if+unless">if the named property is
  444. set</a>.</td>
  445. <td>No</td>
  446. </tr>
  447. <tr>
  448. <td>unless</td>
  449. <td>Only run the tests <a href="../properties.html#if+unless">if the named property
  450. is <strong>not</strong> set</a>.</td>
  451. <td>No</td>
  452. </tr>
  453. <tr>
  454. <td>includeEngines</td>
  455. <td>A comma separated set of test engine ids. If specified, only these test engine(s)
  456. will be used for running the tests.
  457. <br/>
  458. For example: <code>includeEngines="junit-jupiter"</code> will only use the Jupiter
  459. test engine for execution of the tests and will ignore any other engines that might
  460. have been found in the classpath.
  461. </td>
  462. <td>No</td>
  463. </tr>
  464. <tr>
  465. <td>excludeEngines</td>
  466. <td>A comma separated set of test engine ids. If specified, these test engine(s)
  467. will be excluded when running the tests.
  468. <br/>
  469. For example: <code>excludeEngines="junit-vintage"</code> will exclude the vintage
  470. test engine during execution of the tests and will use any other engines that might
  471. have been found in the classpath.
  472. </td>
  473. <td>No</td>
  474. </tr>
  475. </table>
  476. <p>
  477. <code>testclasses</code> can define their own listeners via nested <code>listener</code>
  478. elements.
  479. </p>
  480. <h3>Examples</h3>
  481. <p>
  482. Launch the JUnit 5 platform to run the <samp>org.myapp.SimpleTest</samp> test
  483. </p>
  484. <pre>
  485. &lt;path id="test.classpath"&gt;
  486. ...
  487. &lt;/path&gt;
  488. &lt;junitlauncher&gt;
  489. &lt;classpath refid="test.classpath"/&gt;
  490. &lt;test name="org.myapp.SimpleTest"/&gt;
  491. &lt;/junitlauncher&gt;</pre>
  492. <p>
  493. Launch the JUnit 5 platform to run the <samp>org.myapp.SimpleTest</samp> and
  494. the <samp>org.myapp.AnotherTest</samp> tests. The build process will be stopped if any test, in
  495. the <samp>org.myapp.SimpleTest</samp>, fails.
  496. </p>
  497. <pre>
  498. &lt;junitlauncher&gt;
  499. &lt;classpath refid="test.classpath"/&gt;
  500. &lt;test name="org.myapp.SimpleTest" haltOnFailure="true"/&gt;
  501. &lt;test name="org.myapp.AnotherTest"/&gt;
  502. &lt;/junitlauncher&gt;
  503. </pre>
  504. <p>
  505. Launch the JUnit 5 platform to run only the <samp>testFoo</samp> and <samp>testBar</samp>
  506. methods of the <samp>org.myapp.SimpleTest</samp> test class.
  507. </p>
  508. <pre>
  509. &lt;junitlauncher&gt;
  510. &lt;classpath refid="test.classpath"/&gt;
  511. &lt;test name="org.myapp.SimpleTest" methods="testFoo, testBar"/&gt;
  512. &lt;/junitlauncher&gt;</pre>
  513. <p>
  514. Select any <samp>.class</samp> files that match
  515. the <samp>org/example/**/tests/**/</samp> <code>fileset</code> filter, under
  516. the <samp>${build.classes.dir}</samp> and passes those classes to the JUnit 5 platform for
  517. execution as tests.
  518. </p>
  519. <pre>
  520. &lt;junitlauncher&gt;
  521. &lt;classpath refid="test.classpath"/&gt;
  522. &lt;testclasses outputdir="${output.dir}"&gt;
  523. &lt;fileset dir="${build.classes.dir}"&gt;
  524. &lt;include name="org/example/**/tests/**/"/&gt;
  525. &lt;/fileset&gt;
  526. &lt;/testclasses&gt;
  527. &lt;/junitlauncher&gt;</pre>
  528. <p>
  529. Select any <samp>.class</samp> files that match
  530. the <samp>org/example/**/tests/**/</samp> <code>fileset</code> filter, under
  531. the <samp>${build.classes.dir}</samp> and pass those classes to the JUnit 5 platform for
  532. execution as tests. Test results will be written out to the <samp>${output.dir}</samp> by
  533. the <q>legacy-xml</q> and <q>legacy-plain</q> formatters, in separate files. Furthermore, both
  534. the <q>legacy-xml</q> and the <q>legacy-plain</q> listeners, above, are configured to receive
  535. the standard output content generated by the tests. The <q>legacy-xml</q> listener is configured
  536. to receive standard error content as well.
  537. </p>
  538. <pre>
  539. &lt;junitlauncher&gt;
  540. &lt;classpath refid="test.classpath"/&gt;
  541. &lt;testclasses outputdir="${output.dir}"&gt;
  542. &lt;fileset dir="${build.classes.dir}"&gt;
  543. &lt;include name="org/example/**/tests/**/"/&gt;
  544. &lt;/fileset&gt;
  545. &lt;listener type="legacy-xml" sendSysOut="true" sendSysErr="true"/&gt;
  546. &lt;listener type="legacy-plain" sendSysOut="true" /&gt;
  547. &lt;/testclasses&gt;
  548. &lt;/junitlauncher&gt;</pre>
  549. </body>
  550. </html>