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.9 KiB

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