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.

junitreport.html 6.7 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <!DOCTYPE html>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. https://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <html lang="en">
  17. <head>
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>JUnitReport Task</title>
  20. </head>
  21. <body>
  22. <h2 id="junitreport">JUnitReport</h2>
  23. <h3>Description</h3>
  24. <p>Merge the individual XML files generated by the <code>JUnit</code> task and eventually apply a
  25. stylesheet on the resulting merged document to provide a browsable report of the testcases
  26. results.</p>
  27. <p><strong>Note</strong>: This task depends on external libraries not included in the Apache Ant
  28. distribution. See <a href="../install.html#librarydependencies">Library Dependencies</a> for more
  29. information.</p>
  30. <h3>Parameters</h3>
  31. <table class="attr">
  32. <tr>
  33. <th scope="col">Attribute</th>
  34. <th scope="col">Description</th>
  35. <th scope="col">Required</th>
  36. </tr>
  37. <tr>
  38. <td>tofile</td>
  39. <td>The name of the XML file that will aggregate all individual XML testsuites previously
  40. generated by the <code>JUnit</code> task.</td>
  41. <td>No; defaults to <samp>TESTS-TestSuites.xml</samp></td>
  42. </tr>
  43. <tr>
  44. <td>todir</td>
  45. <td>The directory where the file resulting from the individual XML testsuite aggregation should
  46. be written.</td>
  47. <td>No; defaults to current directory</td>
  48. </tr>
  49. </table>
  50. <h3 id="nested">Parameters specified as nested elements</h3>
  51. <h4>fileset</h4>
  52. <p><code>junitreport</code> collects individual xml files generated by the <code>JUnit</code> task
  53. using the nested <a href="../Types/fileset.html"><code>&lt;FileSet&gt;</code></a> element.</p>
  54. <h4>report</h4>
  55. <p>Generate a browsable report based on the document created by the merge.</p>
  56. <h3>Parameters</h3>
  57. <table class="attr">
  58. <tr>
  59. <th scope="col">Attribute</th>
  60. <th scope="col">Description</th>
  61. <th scope="col">Required</th>
  62. </tr>
  63. <tr>
  64. <td>format</td>
  65. <td>The format of the generated report. Must be either <q>noframes</q> or <q>frames</q>.</td>
  66. <td>No; defaults to <q>frames</q></td>
  67. </tr>
  68. <tr>
  69. <td>styledir</td>
  70. <td>The directory where the stylesheets are defined. They must be conforming to the following
  71. conventions:
  72. <ul>
  73. <li><q>frames</q> format: the stylesheet must be named <samp>junit-frames.xsl</samp>,
  74. or <samp>junit-frames-saxon.xsl</samp> if you are using Saxon 9+.</li>
  75. <li><q>noframes</q> format: the stylesheet must be named <samp>junit-noframes.xsl</samp>,
  76. or <samp>junit-noframes-saxon.xsl</samp> if you are using Saxon 9+.</li>
  77. </ul>
  78. </td>
  79. <td>No; defaults to embedded stylesheets</td>
  80. </tr>
  81. <tr>
  82. <td>todir</td>
  83. <td>The directory where the files resulting from the transformation should be written to.</td>
  84. <td>No; defaults to current directory</td>
  85. </tr>
  86. </table>
  87. <p>Ant assumes the following concerning the <q>frames</q> and <q>noframes</q> formats:</p>
  88. <ul>
  89. <li>The <q>frames</q> format uses a stylesheet which is generating output <em>only</em> by
  90. redirecting.</li>
  91. <li>The <q>noframes</q> format does not use redirecting and generates one file
  92. called <samp>junit-noframes.html</samp>.</li>
  93. </ul>
  94. <p>Custom versions of <samp>junit-frames.xsl</samp> or <samp>junit-noframes.xsl</samp> must adhere
  95. to the above conventions.</p>
  96. <h3>Nested element of the report tag</h3>
  97. <h4>param</h4>
  98. <p><em>Since Ant 1.7</em>, the <var>report</var> tag supports nested <code>param</code> tags. These
  99. tags can pass XSL parameters to the stylesheet.</p>
  100. <h3>Parameters</h3>
  101. <table class="attr">
  102. <tr>
  103. <th scope="col">Attribute</th>
  104. <th scope="col">Description</th>
  105. <th scope="col">Required</th>
  106. </tr>
  107. <tr>
  108. <td>name</td>
  109. <td>Name of the XSL parameter</td>
  110. <td>Yes</td>
  111. </tr>
  112. <tr>
  113. <td>expression</td>
  114. <td>Text value to be placed into the <code>param</code>.<br/>Was originally intended to be an
  115. XSL expression.</td>
  116. <td>Yes</td>
  117. </tr>
  118. <tr>
  119. <td>if</td>
  120. <td>The <code>param</code> will only be passed <a href="../properties.html#if+unless">if this
  121. property is set</a>.</td>
  122. <td>No</td>
  123. </tr>
  124. <tr>
  125. <td>unless</td>
  126. <td>The <code>param</code> will not be passed <a href="../properties.html#if+unless">if this
  127. property is set</a>.</td>
  128. <td>No</td>
  129. </tr>
  130. </table>
  131. <p>The built-in stylesheets support the following parameters:</p>
  132. <table>
  133. <tr>
  134. <th scope="col">XSL Parameter</th>
  135. <th scope="col">Description</th>
  136. <th scope="col">Required</th>
  137. </tr>
  138. <tr>
  139. <td>TITLE</td>
  140. <td>Title used in <code>&lt;title&gt;</code> and <code>&lt;h1&gt;</code> tags</td>
  141. <td>No; defaults to <q>Unit Test Results</q></td>
  142. </tr>
  143. </table>
  144. <h4>classpath</h4>
  145. <p><em>Since Ant 1.9.5</em>. Like for the <a href="../Tasks/style.html#classpath">XSLT task</a>, a
  146. nested <code>&lt;classpath&gt;</code> will be used to load the processor.</p>
  147. <h4>factory</h4>
  148. <p><em>Since Ant 1.9.5</em>. Like for the <a href="../Tasks/style.html#factory">XSLT task</a>, a
  149. nested <code>&lt;factory&gt;</code> can be used to specify factory settings.</p>
  150. <h3>Examples</h3>
  151. <p>Generate a <samp>TESTS-TestSuites.xml</samp> file in the directory <samp>reports</samp> and
  152. generate the default framed report in the directory <samp>report/html</samp>.</p>
  153. <pre>
  154. &lt;junitreport todir=&quot;./reports&quot;&gt;
  155. &lt;fileset dir=&quot;./reports&quot;&gt;
  156. &lt;include name=&quot;TEST-*.xml&quot;/&gt;
  157. &lt;/fileset&gt;
  158. &lt;report format=&quot;frames&quot; todir=&quot;./report/html&quot;/&gt;
  159. &lt;/junitreport&gt;</pre>
  160. <p>This example requires a file called <samp>junitreport/junit-frames.xsl</samp>. The XSL
  161. parameters <q>key1</q> and <q>key2</q> will be passed to the XSL transformation.</p>
  162. <pre>
  163. &lt;junitreport todir="${outputdir}"&gt;
  164. &lt;fileset dir="${jrdir}"&gt;
  165. &lt;include name="TEST-*.xml"/&gt;
  166. &lt;/fileset&gt;
  167. &lt;report todir="${outputdir}/html"
  168. styledir="junitreport"
  169. format="frames"&gt;
  170. &lt;param name="key1" expression="value1"/&gt;
  171. &lt;param name="key2" expression="value2"/&gt;
  172. &lt;/report&gt;
  173. &lt;/junitreport&gt;</pre>
  174. </body>
  175. </html>