git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@112724 13f79535-47bb-0310-9956-ffa450edef68
238 lines
7.7 KiB
Plaintext
238 lines
7.7 KiB
Plaintext
#######################################################################
|
|
## J U N I T D V S L S T Y L E S H E E T ##
|
|
#######################################################################
|
|
|
|
## This stylesheet is used to transform the output of JUnit's xml
|
|
## generator. The XML is transformed into a standard xdoc that can
|
|
## then be transformed (yet again) using whatever stylesheet is used
|
|
## to format one's site.
|
|
##
|
|
## Based on the XSL stylesheet junit-noframes.xsl from Ant.
|
|
##
|
|
## Version: $Id: cactus.dvsl,v 1.1 2003/01/24 03:44:37 jvanzyl Exp $
|
|
|
|
#######################################################################
|
|
## G L O B A L V A R I A B L E S ##
|
|
#######################################################################
|
|
|
|
## Used to facilitate quoting in the template.
|
|
##
|
|
#set ($quote = '"')
|
|
|
|
#######################################################################
|
|
## V E L O C I T Y M A C R O S ##
|
|
#######################################################################
|
|
|
|
## Convert a string that represents a number using the specified
|
|
## pattern.
|
|
##
|
|
#macro (formatAsNumber $string $pattern)
|
|
#set ($value = $context.toolbox.numbers.parse($string))
|
|
$context.toolbox.formatter.formatNumber($value, $pattern)
|
|
#end
|
|
|
|
## Prints a standard navbar for navigation.
|
|
##
|
|
#macro (navbar)
|
|
<p>
|
|
[<a href="#Summary">summary</a>]
|
|
[<a href="#Package List">package list</a>]
|
|
[<a href="#Test Cases">test cases</a>]
|
|
</p>
|
|
#end
|
|
|
|
## Prints a standard header for a test suite.
|
|
##
|
|
#macro (testSuiteHeader)
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Tests</th>
|
|
<th>Errors</th>
|
|
<th>Failures</th>
|
|
<th>Time(s)</th>
|
|
</tr>
|
|
#end
|
|
|
|
## Prints a standard header for a test case.
|
|
##
|
|
#macro (testCaseHeader)
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Status</th>
|
|
<th>Type</th>
|
|
<th>Time(s)</th>
|
|
</tr>
|
|
#end
|
|
|
|
## Prints the message from a failure.
|
|
##
|
|
#macro (displayFailure $current)
|
|
#if ($current.attribute("message"))
|
|
$context.toolbox.htmlescape.getText($current.attribute("message"))
|
|
#else
|
|
N/A
|
|
#end
|
|
<p/>
|
|
<code>
|
|
$context.toolbox.htmlescape.getText($current.value())
|
|
</code>
|
|
#end
|
|
|
|
## Generates the report if unit tests were present.
|
|
##
|
|
#macro (generateReport)
|
|
#navbar ()
|
|
<p>
|
|
The following document contains the results of the <a
|
|
href="http://jakarta.apache.org/cactus">Cactus</a> tests.
|
|
</p>
|
|
</section>
|
|
|
|
###################################################################
|
|
<section name="Summary">
|
|
#navbar ()
|
|
#set ($testCount = $node.valueOf("sum(testsuite/@tests)"))
|
|
#set ($errorCount = $node.valueOf("sum(testsuite/@errors)"))
|
|
#set ($failureCount = $node.valueOf("sum(testsuite/@failures)"))
|
|
#set ($timeCount = $node.valueOf("sum(testsuite/@time)"))
|
|
#set ($successRate = $node.valueOf("($testCount - ($failureCount + $errorCount)) div $testCount"))
|
|
<table>
|
|
<tr>
|
|
<th>Tests</th>
|
|
<th>Errors</th>
|
|
<th>Failures</th>
|
|
<th>Success rate</th>
|
|
<th>Time(s)</th>
|
|
</tr>
|
|
<tr>
|
|
<td>#formatAsNumber ($testCount "0")</td>
|
|
<td>#formatAsNumber ($errorCount "0")</td>
|
|
<td>#formatAsNumber ($failureCount "0")</td>
|
|
<td>#formatAsNumber ($successRate "0.00%")</td>
|
|
<td>#formatAsNumber ($timeCount "0.000")</td>
|
|
</tr>
|
|
</table>
|
|
<p>
|
|
Note: <i>failures</i> are anticipated and checked for with
|
|
assertions while <i>errors</i> are unanticipated.
|
|
</p>
|
|
</section>
|
|
|
|
###################################################################
|
|
<section name="Package List">
|
|
#navbar ()
|
|
<table>
|
|
#testSuiteHeader ()
|
|
#foreach ($testsuite in $node.selectNodes("./testsuite[not(./@package = preceding-sibling::testsuite/@package)]"))
|
|
#set ($package = $testsuite.attribute('package'))
|
|
#set ($quotedPackage = "$quote$package$quote")
|
|
#set ($testCount = $node.valueOf("sum(./testsuite[./@package = $quotedPackage]/@tests)"))
|
|
#set ($errorCount = $node.valueOf("sum(./testsuite[./@package = $quotedPackage]/@errors)"))
|
|
#set ($failureCount = $node.valueOf("sum(./testsuite[./@package = $quotedPackage]/@failures)"))
|
|
#set ($timeCount = $node.valueOf("sum(./testsuite[./@package = $quotedPackage]/@time)"))
|
|
<tr>
|
|
<td><a href="#$package">$package</a></td>
|
|
<td>#formatAsNumber ($testCount "0")</td>
|
|
<td>#formatAsNumber ($failureCount "0")</td>
|
|
<td>#formatAsNumber ($errorCount "0")</td>
|
|
<td>#formatAsNumber ($timeCount "0.000")</td>
|
|
</tr>
|
|
#end
|
|
</table>
|
|
<p>
|
|
Note: package statistics are not computed recursively, they only
|
|
sum up all of its testsuites numbers.
|
|
</p>
|
|
|
|
#foreach ($testsuite in $node.selectNodes("./testsuite[not(./@package = preceding-sibling::testsuite/@package)]"))
|
|
#set ($package = "$testsuite.attribute('package')")
|
|
#set ($quotedPackage = "$quote$package$quote")
|
|
<subsection name="$package">
|
|
<table>
|
|
#testSuiteHeader ()
|
|
#foreach ($test in $node.selectNodes("/testsuites/testsuite[./@package = $quotedPackage]"))
|
|
<tr>
|
|
<td><a href="#$test.attribute('name')">$test.attribute('name')</a></td>
|
|
<td>#formatAsNumber ($test.attribute('tests') "0")</td>
|
|
<td>#formatAsNumber ($test.attribute('errors') "0")</td>
|
|
<td>#formatAsNumber ($test.attribute('failures') "0")</td>
|
|
<td>#formatAsNumber ($test.attribute('time') "0.000")</td>
|
|
</tr>
|
|
#end
|
|
</table>
|
|
</subsection>
|
|
#end
|
|
</section>
|
|
|
|
###################################################################
|
|
<section name="Test Cases">
|
|
#navbar ()
|
|
#foreach ($testsuite in $node.selectNodes("./testsuite"))
|
|
<subsection name="$testsuite.attribute('name')">
|
|
<table>
|
|
#testCaseHeader ()
|
|
|
|
## test can even not be started at all (failure to load the class)
|
|
## so report the error directly
|
|
##
|
|
#foreach ($error in $testsuite.selectNodes("./error"))
|
|
<tr> <td colspan="4"> #displayFailure ($error) </td> </tr>
|
|
#end
|
|
|
|
#foreach ($testcase in $testsuite.selectNodes("./testcase"))
|
|
<tr>
|
|
<td>$testcase.attribute("name")</td>
|
|
#if ($testcase.get("failure"))
|
|
<td>Failure</td>
|
|
<td> #displayFailure ($testcase.selectSingleNode("failure")) </td>
|
|
#elseif ($testcase.get("error"))
|
|
<td>Error</td>
|
|
<td> #displayFailure ($testcase.selectSingleNode("error")) </td>
|
|
#else
|
|
<td>Success</td>
|
|
<td></td>
|
|
#end
|
|
#if ($testcase.attribute("time"))
|
|
<td>#formatAsNumber ($testcase.attribute("time") "0.000")</td>
|
|
#else
|
|
<td></td>
|
|
#end
|
|
</tr>
|
|
#end
|
|
</table>
|
|
</subsection>
|
|
#end
|
|
</section>
|
|
#end
|
|
|
|
#######################################################################
|
|
## T E M P L A T E D E F I N I T I O N S ##
|
|
#######################################################################
|
|
|
|
## Matches the root element of the JUnit XML report.
|
|
##
|
|
#match ("testsuites")
|
|
<?xml version="1.0"?>
|
|
<document>
|
|
|
|
<properties>
|
|
<title>Cactus Test Results</title>
|
|
</properties>
|
|
|
|
<body>
|
|
<section name="Cactus Test Results">
|
|
|
|
#if (! $node.get("testsuite"))
|
|
<p>
|
|
This project does not contain any unit tests.
|
|
</p>
|
|
</section>
|
|
#else
|
|
#generateReport()
|
|
#end
|
|
|
|
</body>
|
|
</document>
|
|
#end
|
|
|