Apache Ant TasksJUnitReportJUnitReportMerge the individual XML files generated by the JUnit task and eventually applya stylesheet on the resulting merged document to provide a browsable report ofthe testcases results.Note: This task depends on external libraries not included inthe Apache Ant distribution. See Library Dependencies for more information. RequirementsThe task needs Apache Xalan 2.4.1+ or Xalan XSLTC(JDK 1.4 contains a version of Xalan-J 2.x while JDK 1.5 ships with aversion of XSLTC). Starting from JDK 1.4.2-01 it ships with a bundledXalan-J 2.4.1+, meaning that JDK version prior to 1.4.2-01 won't workout of the box. The table below summarize the compatibility status. Xalan | Sun JDK Bundle | Status | | 2.4.1+ | JDK 1.4.2-01+ | OK | XSLTC | JDK 1.5.x | OK | 2.x | JDK 1.4.x | DEPRECATED Use ${ant.home}/etc/junit-frames-xalan1.xsl Upgrade Xalan using the JDK endorsement mechanism |
With Ant 1.6.2 we had to decide between supporting Xalan-J 1/Xalan J 2.4.1-and Xalan 2.4.1+/XSLTC, since there was no way to support both couples at the sametime. With Ant 1.7 we had to drop support Xalan-J 1, since Xalan-J 1 has not available anymore for quite some time. Parameters Attribute | Description | Required | tofile | The name of the XML file that will aggregate all individual XML testsuite previously generated by the JUnit task. | No. Default to TESTS-TestSuites.xml | todir | The directory where should be written the file resulting from the individual XML testsuite aggregation. | No. Default to current directory | Nested Elementsfilesetjunitreport collects individual xml files generated by the JUnittask using the nested <FileSet> element.
reportGenerate a browsable report based on the document created by the merge. Parameters Attribute | Description | Required | format | The format of the generated report. Must be "noframes" or "frames". | No, default to "frames" | styledir | The directory where the stylesheets are defined. They must be conforming to the following conventions: - frames format: the stylesheet must be named junit-frames.xsl.
- noframes format: the stylesheet must be named junit-noframes.xsl.
| No. Default to embedded stylesheets. | todir | The directory where the files resulting from the transformation should be written to. | No. Default to current directory | Ant assumes the following concerning the frames and noframes formats : The frames format usesa stylesheet which is generating output only by redirecting. Thenoframes format does not use redirecting and generates onefile called junit-noframes.html. Custom versions of junit-frames.xsl or junit-noframes.xsl must adhere to the above conventions. Nested Element of the report tagparamSince Ant 1.7the report tag supports nested param tags.These tags can pass XSL parameters to the stylesheet.Parameters Attribute | Description | Required | name | Name of the XSL parameter | Yes | expression | Text value to be placed into the param. Was originally intended to be an XSL expression. | Yes | if | The param will only be passed if this property is set. | No | unless | The param will not be passed if this property is set. | No | The built-in stylesheets support the following parameters: XSL-Parameter | Description | Required | TITLE | Title used in <title> and <h1> tags | No. Defaults to Unit Test Results. | Example of report <junitreport todir="./reports"> <fileset dir="./reports"> <include name="TEST-*.xml"/> </fileset> <report format="frames" todir="./report/html"/></junitreport> would generate a TESTS-TestSuites.xml file in the directory reports andgenerate the default framed report in the directory report/html. Example of report with xsl params <junitreport todir="${outputdir}"> <fileset dir="${jrdir}"> <include name="TEST-*.xml"/> </fileset> <report todir="${outputdir}/html" styledir="junitreport" format="frames"> <param name="key1" expression="value1"/> <param name="key2" expression="value2"/> </report></junitreport> This example requires a file called junitreport/junit-frames.xsl. The XSL parameters key1 and key2 will be passed to the XSL transformation. |