2006-09-11 04:19:00 +00:00
|
|
|
<!--
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
-->
|
2001-02-13 12:32:01 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
2005-04-29 18:58:16 +00:00
|
|
|
<link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
|
2002-02-03 22:11:39 +00:00
|
|
|
<title>JUnitReport Task</title>
|
2001-02-13 12:32:01 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
2018-01-22 23:52:21 +01:00
|
|
|
<h2 id="junitreport">JUnitReport</h2>
|
2018-01-20 10:11:35 +01:00
|
|
|
<h3>Description</h3>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Merge the individual XML files generated by the <code>JUnit</code> task and eventually apply a
|
|
|
|
stylesheet on the resulting merged document to provide a browsable report of the testcases
|
|
|
|
results.</p>
|
2018-01-20 10:11:35 +01:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p><strong>Note</strong>: This task depends on external libraries not included in the Apache Ant
|
|
|
|
distribution. See <a href="../install.html#librarydependencies">Library Dependencies</a> for more
|
|
|
|
information.</p>
|
2002-03-14 01:01:18 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Requirements</h3>
|
2004-06-25 13:42:10 +00:00
|
|
|
|
2018-03-08 07:43:53 +01:00
|
|
|
<p>The task needs Apache <a href="https://xml.apache.org/xalan-j/" target="_top">Xalan 2.4.1+ or
|
|
|
|
Xalan XSLTC</a> (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 and later ships with a bundled Xalan 2.4.1+, meaning that JDKs prior to version
|
|
|
|
1.4.2-01 won't work out of the box. The table below summarize the compatibility status.</p>
|
2018-01-22 23:52:21 +01:00
|
|
|
<table>
|
|
|
|
<tr><th>Xalan</th><th>Sun JDK Bundle</th><th>Status<th></tr>
|
2004-07-30 17:47:57 +00:00
|
|
|
<tr><td>2.4.1+</td><td>JDK 1.4.2-01+</td><td>OK</td></tr>
|
|
|
|
<tr><td>XSLTC</td><td>JDK 1.5.x</td><td>OK</td></tr>
|
2018-03-04 10:36:45 +01:00
|
|
|
<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><br/>Upgrade Xalan using the JDK endorsement
|
|
|
|
mechanism</em></td></tr>
|
2004-07-30 17:47:57 +00:00
|
|
|
</table>
|
2004-06-25 13:42:10 +00:00
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>In Ant 1.6.2, we had to decide between supporting Xalan 1/Xalan 2.4.1- and Xalan 2.4.1+/XSLTC,
|
|
|
|
because there was no way to support both couples at the same time.</p>
|
|
|
|
<p><em>Since Ant 1.7</em>, we dropped support for Xalan 1, because Xalan 1 was not available anymore
|
|
|
|
for quite some time.</p>
|
2004-06-25 13:42:10 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Parameters</h3>
|
2018-02-28 07:58:59 +01:00
|
|
|
<table class="attr">
|
2001-02-13 12:32:01 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<th>Attribute</th>
|
|
|
|
<th>Description</th>
|
|
|
|
<th>Required</th>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>tofile</td>
|
|
|
|
<td>The name of the XML file that will aggregate all individual XML testsuites previously
|
|
|
|
generated by the <code>JUnit</code> task.</td>
|
|
|
|
<td>No; defaults to <samp>TESTS-TestSuites.xml</samp></td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>todir</td>
|
|
|
|
<td>The directory where the file resulting from the individual XML testsuite aggregation should
|
|
|
|
be written.</td>
|
|
|
|
<td>No; defaults to current directory</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
2018-03-05 17:35:30 +01:00
|
|
|
<h3 id="nested">Parameters specified as nested elements</h3>
|
2001-02-13 12:32:01 +00:00
|
|
|
<h4>fileset</h4>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p><code>junitreport</code> collects individual xml files generated by the <code>JUnit</code> task
|
|
|
|
using the nested <a href="../Types/fileset.html"><code><FileSet></code></a> element.</p>
|
2001-02-13 12:32:01 +00:00
|
|
|
<h4>report</h4>
|
|
|
|
<p>Generate a browsable report based on the document created by the merge.</p>
|
|
|
|
<h3>Parameters</h3>
|
2018-02-28 07:58:59 +01:00
|
|
|
<table class="attr">
|
2001-02-13 12:32:01 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<th>Attribute</th>
|
|
|
|
<th>Description</th>
|
|
|
|
<th>Required</th>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>format</td>
|
|
|
|
<td>The format of the generated report. Must be either <q>noframes</q> or <q>frames</q>.</td>
|
|
|
|
<td>No; defaults to <q>frames</q></td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>styledir</td>
|
|
|
|
<td>The directory where the stylesheets are defined. They must be conforming to the following
|
|
|
|
conventions:
|
2001-02-13 12:32:01 +00:00
|
|
|
<ul>
|
2018-03-04 10:36:45 +01:00
|
|
|
<li><q>frames</q> format: the stylesheet must be named <samp>junit-frames.xsl</samp>,
|
|
|
|
or <samp>junit-frames-saxon.xsl</samp> if you are using Saxon 9+.</li>
|
|
|
|
<li><q>noframes</q> format: the stylesheet must be named <samp>junit-noframes.xsl</samp>,
|
|
|
|
or <samp>junit-noframes-saxon.xsl</samp> if you are using Saxon 9+.</li>
|
2001-02-13 12:32:01 +00:00
|
|
|
</ul>
|
|
|
|
</td>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>No; defaults to embedded stylesheets</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>todir</td>
|
|
|
|
<td>The directory where the files resulting from the transformation should be written to.</td>
|
|
|
|
<td>No; defaults to current directory</td>
|
2001-02-13 12:32:01 +00:00
|
|
|
</tr>
|
|
|
|
</table>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>Ant assumes the following concerning the <q>frames</q> and <q>noframes</q> formats:</p>
|
|
|
|
<ul>
|
|
|
|
<li>The <q>frames</q> format uses a stylesheet which is generating output <em>only</em> by
|
|
|
|
redirecting.</li>
|
|
|
|
<li>The <q>noframes</q> format does not use redirecting and generates one file
|
|
|
|
called <samp>junit-noframes.html</samp>.</li>
|
|
|
|
</ul>
|
|
|
|
<p>Custom versions of <samp>junit-frames.xsl</samp> or <samp>junit-noframes.xsl</samp> must adhere
|
|
|
|
to the above conventions.</p>
|
2006-07-12 19:05:29 +00:00
|
|
|
|
2018-03-05 21:01:42 +01:00
|
|
|
<h3>Nested element of the report tag</h3>
|
2006-06-30 23:42:17 +00:00
|
|
|
<h4>param</h4>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p><em>Since Ant 1.7</em>, the <var>report</var> tag supports nested <code>param</code> tags. These
|
|
|
|
tags can pass XSL parameters to the stylesheet.</p>
|
2006-06-30 23:42:17 +00:00
|
|
|
<h3>Parameters</h3>
|
2018-02-28 07:58:59 +01:00
|
|
|
<table class="attr">
|
2006-06-30 23:42:17 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<th>Attribute</th>
|
|
|
|
<th>Description</th>
|
|
|
|
<th>Required</th>
|
2006-06-30 23:42:17 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>name</td>
|
|
|
|
<td>Name of the XSL parameter</td>
|
|
|
|
<td>Yes</td>
|
2006-06-30 23:42:17 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>expression</td>
|
|
|
|
<td>Text value to be placed into the <code>param</code>.<br/>Was originally intended to be an
|
|
|
|
XSL expression.</td>
|
|
|
|
<td>Yes</td>
|
2006-06-30 23:42:17 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>if</td>
|
|
|
|
<td>The <code>param</code> will only be passed <a href="../properties.html#if+unless">if this
|
|
|
|
property is set</a>.</td>
|
|
|
|
<td>No</td>
|
2006-06-30 23:42:17 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>unless</td>
|
|
|
|
<td>The <code>param</code> will not be passed <a href="../properties.html#if+unless">if this
|
|
|
|
property is set</a>.</td>
|
|
|
|
<td>No</td>
|
2006-06-30 23:42:17 +00:00
|
|
|
</tr>
|
2007-03-05 09:38:37 +00:00
|
|
|
</table>
|
2006-06-30 23:42:17 +00:00
|
|
|
|
2007-03-05 09:38:37 +00:00
|
|
|
<p>The built-in stylesheets support the following parameters:</p>
|
2018-01-22 23:52:21 +01:00
|
|
|
<table>
|
2007-03-05 09:38:37 +00:00
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<th>XSL Parameter</th>
|
|
|
|
<th>Description</th>
|
|
|
|
<th>Required</th>
|
2007-03-05 09:38:37 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2018-02-28 07:58:59 +01:00
|
|
|
<td>TITLE</td>
|
|
|
|
<td>Title used in <code><title></code> and <code><h1></code> tags</td>
|
|
|
|
<td>No; defaults to <q>Unit Test Results</q></td>
|
2007-03-05 09:38:37 +00:00
|
|
|
</tr>
|
2006-06-30 23:42:17 +00:00
|
|
|
</table>
|
2007-03-05 09:38:37 +00:00
|
|
|
|
junitreport: Expose classpath and factory of internal XSLTProcess task.
This patch creates the nested XSLTProcess at creation of the
AggregateTransformer, not upon execution of the transformation. This way it
is much easier to simply wrap parts of the interface I'd like to expose,
like the new <classpath> and <factory> nested elements, but also the
existing <param> elements.
I haven't called XSLTProcess.init(), as the previous code didn't do that
either. I don't fully understand the difference between init() and a
constructor, but it might be a good thing to init the task somewhere.
The approach I chose is something like a whitelist delegation: the
XSLTProcess is a private member, and only selected methods of its interface
are wrapped and thus exposed to be configured. As an alternative, one could
do something like a blacklist delegation by deriving a class from
XSLTProcess and forbidding access to certain settings by ovverriding the
corresponding methods and throwing exceptions therein. In that case, one
might even turn the class derived from XSLTProcess into a nested <xslt>
element, which would be probably much clearer, as it would be configured in
the same way that a top-level <xslt> task is. I didn't choose this approach
in my patch for now.
2014-11-26 13:50:50 +01:00
|
|
|
<h4>classpath</h4>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p><em>Since Ant 1.9.5</em>. Like for the <a href="../Tasks/style.html#classpath">XSLT task</a>, a
|
|
|
|
nested <code><classpath></code> will be used to load the processor.</p>
|
junitreport: Expose classpath and factory of internal XSLTProcess task.
This patch creates the nested XSLTProcess at creation of the
AggregateTransformer, not upon execution of the transformation. This way it
is much easier to simply wrap parts of the interface I'd like to expose,
like the new <classpath> and <factory> nested elements, but also the
existing <param> elements.
I haven't called XSLTProcess.init(), as the previous code didn't do that
either. I don't fully understand the difference between init() and a
constructor, but it might be a good thing to init the task somewhere.
The approach I chose is something like a whitelist delegation: the
XSLTProcess is a private member, and only selected methods of its interface
are wrapped and thus exposed to be configured. As an alternative, one could
do something like a blacklist delegation by deriving a class from
XSLTProcess and forbidding access to certain settings by ovverriding the
corresponding methods and throwing exceptions therein. In that case, one
might even turn the class derived from XSLTProcess into a nested <xslt>
element, which would be probably much clearer, as it would be configured in
the same way that a top-level <xslt> task is. I didn't choose this approach
in my patch for now.
2014-11-26 13:50:50 +01:00
|
|
|
|
|
|
|
<h4>factory</h4>
|
2018-02-28 07:58:59 +01:00
|
|
|
<p><em>Since Ant 1.9.5</em>. Like for the <a href="../Tasks/style.html#factory">XSLT task</a>, a
|
|
|
|
nested <code><factory></code> can be used to specify factory settings.</p>
|
2007-03-05 09:38:37 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
<h3>Example of report</h3>
|
2018-02-28 07:58:59 +01:00
|
|
|
<pre>
|
|
|
|
<junitreport todir="./reports">
|
|
|
|
<fileset dir="./reports">
|
|
|
|
<include name="TEST-*.xml"/>
|
|
|
|
</fileset>
|
|
|
|
<report format="frames" todir="./report/html"/>
|
2018-02-09 06:54:03 +01:00
|
|
|
</junitreport></pre>
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>would generate a <samp>TESTS-TestSuites.xml</samp> file in the directory <samp>reports</samp> and
|
|
|
|
generate the default framed report in the directory <samp>report/html</samp>.</p>
|
2018-02-09 06:54:03 +01:00
|
|
|
|
2018-03-05 21:01:42 +01:00
|
|
|
<h3>Example of report with XSL params</h3>
|
2018-02-09 06:54:03 +01:00
|
|
|
<pre>
|
2006-06-30 23:42:17 +00:00
|
|
|
<junitreport todir="${outputdir}">
|
|
|
|
<fileset dir="${jrdir}">
|
|
|
|
<include name="TEST-*.xml"/>
|
|
|
|
</fileset>
|
|
|
|
<report todir="${outputdir}/html"
|
2018-03-05 21:01:42 +01:00
|
|
|
styledir="junitreport"
|
|
|
|
format="frames">
|
2006-06-30 23:42:17 +00:00
|
|
|
<param name="key1" expression="value1"/>
|
|
|
|
<param name="key2" expression="value2"/>
|
|
|
|
</report>
|
2018-02-09 06:54:03 +01:00
|
|
|
</junitreport></pre>
|
|
|
|
|
2018-02-28 07:58:59 +01:00
|
|
|
<p>This example requires a file called <samp>junitreport/junit-frames.xsl</samp>. The XSL
|
|
|
|
parameters <q>key1</q> and <q>key2</q> will be passed to the XSL transformation.</p>
|
2006-09-11 04:33:25 +00:00
|
|
|
|
2001-02-13 12:32:01 +00:00
|
|
|
</body>
|
|
|
|
</html>
|