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 7.6 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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>JUnitReport Task</title>
  19. </head>
  20. <body>
  21. <h2 id="junitreport">JUnitReport</h2>
  22. <h3>Description</h3>
  23. <p>Merge the individual XML files generated by the <code>JUnit</code> task and eventually apply a
  24. stylesheet on the resulting merged document to provide a browsable report of the testcases
  25. results.</p>
  26. <p><strong>Note</strong>: This task depends on external libraries not included in the Apache Ant
  27. distribution. See <a href="../install.html#librarydependencies">Library Dependencies</a> for more
  28. information.</p>
  29. <h3>Requirements</h3>
  30. <p>The task needs Apache <a href="https://xml.apache.org/xalan-j/">Xalan 2.4.1+ or Xalan XSLTC</a>
  31. (JDK 1.4 contains a version of Xalan 2.x, while JDK 1.5 ships with a version of XSLTC). JDK 1.4.2-01
  32. and later ships with a bundled Xalan 2.4.1+, meaning that JDKs prior to version 1.4.2-01 won't work
  33. out of the box. The table below summarize the compatibility status.</p>
  34. <table>
  35. <tr><th>Xalan</th><th>Sun JDK Bundle</th><th>Status<th></tr>
  36. <tr><td>2.4.1+</td><td>JDK 1.4.2-01+</td><td>OK</td></tr>
  37. <tr><td>XSLTC</td><td>JDK 1.5.x</td><td>OK</td></tr>
  38. <tr><td>2.x</td><td>JDK 1.4.x</td><td><em><u>Deprecated</u>, use <samp>${ant.home}/etc/junit-frames-xalan1.xsl</samp>
  39. <br/>Upgrade Xalan using the JDK endorsement mechanism</em></td></tr>
  40. </table>
  41. <p>In Ant 1.6.2, we had to decide between supporting Xalan 1/Xalan 2.4.1- and Xalan 2.4.1+/XSLTC,
  42. because there was no way to support both couples at the same time.</p>
  43. <p><em>Since Ant 1.7</em>, we dropped support for Xalan 1, because Xalan 1 was not available anymore
  44. for quite some time.</p>
  45. <h3>Parameters</h3>
  46. <table class="attr">
  47. <tr>
  48. <th>Attribute</th>
  49. <th>Description</th>
  50. <th>Required</th>
  51. </tr>
  52. <tr>
  53. <td>tofile</td>
  54. <td>The name of the XML file that will aggregate all individual XML testsuites previously
  55. generated by the <code>JUnit</code> task.</td>
  56. <td>No; defaults to <samp>TESTS-TestSuites.xml</samp></td>
  57. </tr>
  58. <tr>
  59. <td>todir</td>
  60. <td>The directory where the file resulting from the individual XML testsuite aggregation should
  61. be written.</td>
  62. <td>No; defaults to current directory</td>
  63. </tr>
  64. </table>
  65. <h3 id="nested">Nested Elements</h3>
  66. <h4>fileset</h4>
  67. <p><code>junitreport</code> collects individual xml files generated by the <code>JUnit</code> task
  68. using the nested <a href="../Types/fileset.html"><code>&lt;FileSet&gt;</code></a> element.</p>
  69. <h4>report</h4>
  70. <p>Generate a browsable report based on the document created by the merge.</p>
  71. <h3>Parameters</h3>
  72. <table class="attr">
  73. <tr>
  74. <th>Attribute</th>
  75. <th>Description</th>
  76. <th>Required</th>
  77. </tr>
  78. <tr>
  79. <td>format</td>
  80. <td>The format of the generated report. Must be either <q>noframes</q> or <q>frames</q>.</td>
  81. <td>No; defaults to <q>frames</q></td>
  82. </tr>
  83. <tr>
  84. <td>styledir</td>
  85. <td>The directory where the stylesheets are defined. They must be conforming to the following
  86. conventions:
  87. <ul>
  88. <li><q>frames</q> format: the stylesheet must be named <samp>junit-frames.xsl</samp>, or <i>junit-frames-saxon.xsl if you are using Saxon 9+.</li>
  89. <li><q>noframes</q> format: the stylesheet must be named <samp>junit-noframes.xsl</samp>, or <i>junit-noframes-saxon.xsl if you are using Saxon 9+.</li>
  90. </ul>
  91. </td>
  92. <td>No; defaults to embedded stylesheets</td>
  93. </tr>
  94. <tr>
  95. <td>todir</td>
  96. <td>The directory where the files resulting from the transformation should be written to.</td>
  97. <td>No; defaults to current directory</td>
  98. </tr>
  99. </table>
  100. <p>Ant assumes the following concerning the <q>frames</q> and <q>noframes</q> formats:</p>
  101. <ul>
  102. <li>The <q>frames</q> format uses a stylesheet which is generating output <em>only</em> by
  103. redirecting.</li>
  104. <li>The <q>noframes</q> format does not use redirecting and generates one file
  105. called <samp>junit-noframes.html</samp>.</li>
  106. </ul>
  107. <p>Custom versions of <samp>junit-frames.xsl</samp> or <samp>junit-noframes.xsl</samp> must adhere
  108. to the above conventions.</p>
  109. <h3>Nested Element of the report tag</h3>
  110. <h4>param</h4>
  111. <p><em>Since Ant 1.7</em>, the <var>report</var> tag supports nested <code>param</code> tags. These
  112. tags can pass XSL parameters to the stylesheet.</p>
  113. <h3>Parameters</h3>
  114. <table class="attr">
  115. <tr>
  116. <th>Attribute</th>
  117. <th>Description</th>
  118. <th>Required</th>
  119. </tr>
  120. <tr>
  121. <td>name</td>
  122. <td>Name of the XSL parameter</td>
  123. <td>Yes</td>
  124. </tr>
  125. <tr>
  126. <td>expression</td>
  127. <td>Text value to be placed into the <code>param</code>.<br/>Was originally intended to be an
  128. XSL expression.</td>
  129. <td>Yes</td>
  130. </tr>
  131. <tr>
  132. <td>if</td>
  133. <td>The <code>param</code> will only be passed <a href="../properties.html#if+unless">if this
  134. property is set</a>.</td>
  135. <td>No</td>
  136. </tr>
  137. <tr>
  138. <td>unless</td>
  139. <td>The <code>param</code> will not be passed <a href="../properties.html#if+unless">if this
  140. property is set</a>.</td>
  141. <td>No</td>
  142. </tr>
  143. </table>
  144. <p>The built-in stylesheets support the following parameters:</p>
  145. <table>
  146. <tr>
  147. <th>XSL Parameter</th>
  148. <th>Description</th>
  149. <th>Required</th>
  150. </tr>
  151. <tr>
  152. <td>TITLE</td>
  153. <td>Title used in <code>&lt;title&gt;</code> and <code>&lt;h1&gt;</code> tags</td>
  154. <td>No; defaults to <q>Unit Test Results</q></td>
  155. </tr>
  156. </table>
  157. <h4>classpath</h4>
  158. <p><em>Since Ant 1.9.5</em>. Like for the <a href="../Tasks/style.html#classpath">XSLT task</a>, a
  159. nested <code>&lt;classpath&gt;</code> will be used to load the processor.</p>
  160. <h4>factory</h4>
  161. <p><em>Since Ant 1.9.5</em>. Like for the <a href="../Tasks/style.html#factory">XSLT task</a>, a
  162. nested <code>&lt;factory&gt;</code> can be used to specify factory settings.</p>
  163. <h3>Example of report</h3>
  164. <pre>
  165. &lt;junitreport todir=&quot;./reports&quot;&gt;
  166. &lt;fileset dir=&quot;./reports&quot;&gt;
  167. &lt;include name=&quot;TEST-*.xml&quot;/&gt;
  168. &lt;/fileset&gt;
  169. &lt;report format=&quot;frames&quot; todir=&quot;./report/html&quot;/&gt;
  170. &lt;/junitreport&gt;</pre>
  171. <p>would generate a <samp>TESTS-TestSuites.xml</samp> file in the directory <samp>reports</samp> and
  172. generate the default framed report in the directory <samp>report/html</samp>.</p>
  173. <h3>Example of report with xsl params</h3>
  174. <pre>
  175. &lt;junitreport todir="${outputdir}"&gt;
  176. &lt;fileset dir="${jrdir}"&gt;
  177. &lt;include name="TEST-*.xml"/&gt;
  178. &lt;/fileset&gt;
  179. &lt;report todir="${outputdir}/html"
  180. styledir="junitreport"
  181. format="frames"&gt;
  182. &lt;param name="key1" expression="value1"/&gt;
  183. &lt;param name="key2" expression="value2"/&gt;
  184. &lt;/report&gt;
  185. &lt;/junitreport&gt;</pre>
  186. <p>This example requires a file called <samp>junitreport/junit-frames.xsl</samp>. The XSL
  187. parameters <q>key1</q> and <q>key2</q> will be passed to the XSL transformation.</p>
  188. </body>
  189. </html>