5713N/A<
xsl:
output method="html" indent="yes" encoding="UTF-8" 0N/A doctype-
public="-//W3C//DTD HTML 4.01 Transitional//EN" />
0N/A<
xsl:
decimal-
format decimal-
separator="." grouping-
separator="," />
809N/A Licensed to the Apache Software Foundation (ASF) under one or more 809N/A contributor license agreements. See the NOTICE file distributed with 809N/A this work for additional information regarding copyright ownership. 809N/A The ASF licenses this file to You under the Apache License, Version 2.0 809N/A (the "License"); you may not use this file except in compliance with 809N/A the License. You may obtain a copy of the License at 0N/A Unless required by applicable law or agreed to in writing, software 0N/A distributed under the License is distributed on an "AS IS" BASIS, 0N/A WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0N/A See the License for the specific language governing permissions and 0N/A limitations under the License. 5713N/A<
xsl:
param name="TITLE">Unit Test Results.</
xsl:
param>
0N/A Sample stylesheet to be used with Ant JUnitReport output. 0N/A It creates a non-framed report that can be useful to send via 0N/A<
xsl:
template match="testsuites">
5713N/A <
title><
xsl:
value-
of select="$TITLE"/></
title>
0N/A font:normal 68% verdana,arial,helvetica;
0N/A table tr td, table tr th {
0N/A margin-top:0.5em; margin-bottom:1.0em;
0N/A margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
0N/A margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
0N/A margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
0N/A margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
0N/A margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
0N/A margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
0N/A font-weight:bold; color:red;
0N/A font-weight:bold; color:purple;
0N/A var TestCases = new Array();
0N/A <
xsl:
apply-
templates select="properties"/>
0N/A function displayProperties (name) { 0N/A var win = window.open('','JUnitSystemProperties','scrollbars=1,resizable=1'); 0N/A doc.write("<html><head><title>Properties of " + name + "</title>"); 0N/A doc.write("body {font:normal 68% verdana,arial,helvetica; color:#000000; }"); 0N/A doc.write("table.properties th { text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#eeeeee; }"); 0N/A doc.write("table.properties td { font:normal; text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#fffffff; }"); 0N/A doc.write("h3 { margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica }"); 0N/A for (prop in TestCases[name]) { 0N/A doc.write("<tr><th>" + prop + "</th><td>" + TestCases[name][prop] + "</td></tr>"); 809N/A <
xsl:
call-
template name="pageHeader"/>
0N/A <!-- Summary part --> 0N/A <
xsl:
call-
template name="summary"/>
0N/A <
hr size="1" width="95%" align="left"/>
0N/A <!-- Package List part --> 0N/A <
xsl:
call-
template name="packagelist"/>
0N/A <
hr size="1" width="95%" align="left"/>
0N/A <!-- For each package create its part --> 0N/A <
xsl:
call-
template name="packages"/>
0N/A <
hr size="1" width="95%" align="left"/>
0N/A <!-- For each class create the part --> 0N/A <
xsl:
call-
template name="classes"/>
0N/A <!-- ================================================================== --> 0N/A <!-- Write a list of all packages with an hyperlink to the anchor of --> 0N/A <!-- of the package name. --> 0N/A <!-- ================================================================== --> 809N/A <
xsl:
template name="packagelist">
0N/A Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.
0N/A <
table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
0N/A <!-- list all packages recursively --> 0N/A <
xsl:
for-
each select="/testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
0N/A <
xsl:
sort select="@package"/>
0N/A <
xsl:
variable name="testCount" select="sum($testsuites-in-package/@tests)"/>
0N/A <
xsl:
variable name="errorCount" select="sum($testsuites-in-package/@errors)"/>
0N/A <
xsl:
variable name="failureCount" select="sum($testsuites-in-package/@failures)"/>
0N/A <
xsl:
variable name="timeCount" select="sum($testsuites-in-package/@time)"/>
0N/A <!-- write a summary for the package --> 0N/A <
xsl:
attribute name="class">
0N/A <
xsl:
when test="$failureCount > 0">Failure</
xsl:
when>
0N/A <
xsl:
when test="$errorCount > 0">Error</
xsl:
when>
0N/A <
td><
a href="#{@package}"><
xsl:
value-
of select="@package"/></
a></
td>
0N/A <
td><
xsl:
value-
of select="$testCount"/></
td>
0N/A <
td><
xsl:
value-
of select="$errorCount"/></
td>
0N/A <
td><
xsl:
value-
of select="$failureCount"/></
td>
0N/A <
xsl:
call-
template name="display-time">
0N/A <
xsl:
with-
param name="value" select="$timeCount"/>
0N/A </
xsl:
call-
template>
809N/A <
td><
xsl:
value-
of select="$testsuites-in-package/@timestamp"/></
td>
809N/A <
td><
xsl:
value-
of select="$testsuites-in-package/@hostname"/></
td>
0N/A <!-- ================================================================== --> 0N/A <!-- Write a package level report --> 0N/A <!-- It creates a table with values from the document: --> 0N/A <!-- Name | Tests | Errors | Failures | Time --> 0N/A <!-- ================================================================== --> 0N/A <
xsl:
template name="packages">
0N/A <!-- create an anchor to this package name --> 0N/A <
xsl:
sort select="@package"/>
0N/A <
a name="{@package}"></
a>
0N/A <
h3>Package <
xsl:
value-
of select="@package"/></
h3>
0N/A <
table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
0N/A <!-- match the testsuites of this package --> 0N/A <
a href="#top">Back to top</
a>
0N/A <
xsl:
template name="classes">
0N/A <
xsl:
for-
each select="testsuite">
0N/A <
xsl:
sort select="@name"/>
0N/A <!-- create an anchor to this class name --> 0N/A <
a name="{@name}"></
a>
0N/A <
h3>TestCase <
xsl:
value-
of select="@name"/></
h3>
0N/A <
table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
0N/A test can even not be started at all (failure to load the class) 0N/A so report the error directly 0N/A <
td colspan="4"><
xsl:
apply-
templates select="/error"/></
td>
0N/A <
div class="Properties">
0N/A <
xsl:
attribute name="href">javascript:displayProperties('<
xsl:
value-
of select="@package"/>.<
xsl:
value-
of select="@name"/>');</
xsl:
attribute>
0N/A <
a href="#top">Back to top</
a>
0N/A <
xsl:
template name="summary">
0N/A <
xsl:
variable name="testCount" select="sum(testsuite/@tests)"/>
0N/A <
xsl:
variable name="errorCount" select="sum(testsuite/@errors)"/>
0N/A <
xsl:
variable name="failureCount" select="sum(testsuite/@failures)"/>
0N/A <
xsl:
variable name="timeCount" select="sum(testsuite/@time)"/>
0N/A <
xsl:
variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/>
0N/A <
table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
0N/A <
th>Success rate</
th>
0N/A <
xsl:
attribute name="class">
0N/A <
xsl:
when test="$failureCount > 0">Failure</
xsl:
when>
0N/A <
xsl:
when test="$errorCount > 0">Error</
xsl:
when>
0N/A <
td><
xsl:
value-
of select="$testCount"/></
td>
0N/A <
td><
xsl:
value-
of select="$failureCount"/></
td>
0N/A <
td><
xsl:
value-
of select="$errorCount"/></
td>
0N/A <
xsl:
call-
template name="display-percent">
0N/A <
xsl:
with-
param name="value" select="$successRate"/>
0N/A </
xsl:
call-
template>
0N/A <
xsl:
call-
template name="display-time">
0N/A <
xsl:
with-
param name="value" select="$timeCount"/>
0N/A </
xsl:
call-
template>
0N/A <
table border="0" width="95%">
0N/A <
td style="text-align: justify;">
0N/A Note: <
i>failures</
i> are anticipated and checked for with assertions while <
i>errors</
i> are unanticipated.
0N/A Write properties into a JavaScript data structure. 0N/A This is based on the original idea by Erik Hatcher (ehatcher@apache.org) 0N/A <
xsl:
template match="properties">
0N/A cur = TestCases['<
xsl:
value-
of select="../@package"/>.<
xsl:
value-
of select="../@name"/>'] = new Array();
0N/A <
xsl:
for-
each select="property">
0N/A <
xsl:
sort select="@name"/>
0N/A cur['<
xsl:
value-
of select="@name"/>'] = '<
xsl:
call-
template name="JS-escape"><
xsl:
with-
param name="string" select="@value"/></
xsl:
call-
template>';
0N/A<
xsl:
template name="pageHeader">
5713N/A <
h1><
xsl:
value-
of select="$TITLE"/></
h1>
0N/A <
table width="100%">
0N/A <
td align="left"></
td>
0N/A<
xsl:
template match="testsuite" mode="header">
0N/A <
th width="80%">Name</
th>
0N/A <
th nowrap="nowrap">Time(s)</
th>
0N/A<!-- class header --> 0N/A <
th width="80%">Name</
th>
0N/A <
th nowrap="nowrap">Time(s)</
th>
809N/A <
th nowrap="nowrap">Time Stamp</
th>
0N/A<!-- method header --> 0N/A <
th width="80%">Type</
th>
0N/A <
th nowrap="nowrap">Time(s)</
th>
0N/A<!-- class information --> 0N/A <
xsl:
attribute name="class">
0N/A <
xsl:
when test="@failures[.> 0]">Failure</
xsl:
when>
0N/A <
xsl:
when test="@errors[.> 0]">Error</
xsl:
when>
0N/A <!-- print testsuite information --> 0N/A <
td><
a href="#{@name}"><
xsl:
value-
of select="@name"/></
a></
td>
0N/A <
td><
xsl:
value-
of select="@tests"/></
td>
0N/A <
td><
xsl:
value-
of select="@errors"/></
td>
0N/A <
td><
xsl:
value-
of select="@failures"/></
td>
0N/A <
xsl:
call-
template name="display-time">
0N/A <
xsl:
with-
param name="value" select="@time"/>
0N/A </
xsl:
call-
template>
809N/A <
td><
xsl:
apply-
templates select="@timestamp"/></
td>
809N/A <
td><
xsl:
apply-
templates select="@hostname"/></
td>
0N/A <
xsl:
attribute name="class">
0N/A <
xsl:
when test="failure | error">Error</
xsl:
when>
0N/A <
td><
xsl:
value-
of select="@name"/></
td>
0N/A <
xsl:
when test="failure">
0N/A <
td><
xsl:
apply-
templates select="failure"/></
td>
0N/A <
xsl:
when test="error">
0N/A <
td><
xsl:
apply-
templates select="error"/></
td>
0N/A <
xsl:
call-
template name="display-time">
0N/A <
xsl:
with-
param name="value" select="@time"/>
0N/A </
xsl:
call-
template>
0N/A<
xsl:
template match="failure">
0N/A <
xsl:
call-
template name="display-failures"/>
0N/A<
xsl:
template match="error">
0N/A <
xsl:
call-
template name="display-failures"/>
0N/A<!-- Style for the error and failure in the tescase template --> 0N/A<
xsl:
template name="display-failures">
0N/A <
xsl:
when test="not(@message)">N/A</
xsl:
when>
0N/A <
xsl:
value-
of select="@message"/>
0N/A <!-- display the stacktrace --> 0N/A <
xsl:
call-
template name="br-replace">
0N/A <
xsl:
with-
param name="word" select="."/>
0N/A </
xsl:
call-
template>
0N/A <!-- the later is better but might be problematic for non-21" monitors... --> 0N/A <!--pre><xsl:value-of select="."/></pre--> 0N/A<
xsl:
template name="JS-escape">
0N/A <
xsl:
param name="string"/>
0N/A <
xsl:
param name="tmp1" select="stringutils:replace(string($string),'\','\\')"/>
0N/A <
xsl:
param name="tmp2" select="stringutils:replace(string($tmp1),"'","\'")"/>
0N/A <
xsl:
value-
of select="$tmp2"/>
0N/A template that will convert a carriage return into a br tag 0N/A @param word the text from which to convert CR to BR tag 0N/A<
xsl:
template name="br-replace">
0N/A <
xsl:
param name="word"/>
5713N/A <
xsl:
when test="contains($word, '
')">
5713N/A <
xsl:
value-
of select="substring-before($word, '
')"/>
5713N/A <
xsl:
call-
template name="br-replace">
5713N/A <
xsl:
with-
param name="word" select="substring-after($word, '
')"/>
5713N/A <
xsl:
value-
of select="$word"/>
0N/A<
xsl:
template name="display-time">
0N/A <
xsl:
param name="value"/>
0N/A <
xsl:
value-
of select="format-number($value,'0.000')"/>
0N/A<
xsl:
template name="display-percent">
0N/A <
xsl:
param name="value"/>
0N/A <
xsl:
value-
of select="format-number($value,'0.00%')"/>