junit-noframes.xsl revision 5713
5713N/A<?xml version="1.0"?>
0N/A<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
809N/A xmlns:lxslt="http://xml.apache.org/xslt"
809N/A xmlns:stringutils="xalan://org.apache.tools.ant.util.StringUtils">
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="," />
0N/A<!--
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
0N/A http://www.apache.org/licenses/LICENSE-2.0
0N/A
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.
0N/A -->
809N/A
5713N/A<xsl:param name="TITLE">Unit Test Results.</xsl:param>
5713N/A
0N/A<!--
809N/A
0N/A Sample stylesheet to be used with Ant JUnitReport output.
809N/A
0N/A It creates a non-framed report that can be useful to send via
0N/A e-mail or such.
809N/A
0N/A-->
0N/A<xsl:template match="testsuites">
0N/A <html>
0N/A <head>
5713N/A <title><xsl:value-of select="$TITLE"/></title>
0N/A <style type="text/css">
0N/A body {
0N/A font:normal 68% verdana,arial,helvetica;
0N/A color:#000000;
0N/A }
0N/A table tr td, table tr th {
0N/A font-size: 68%;
0N/A }
0N/A table.details tr th{
0N/A font-weight: bold;
0N/A text-align:left;
0N/A background:#a6caf0;
0N/A }
0N/A table.details tr td{
0N/A background:#eeeee0;
0N/A }
809N/A
0N/A p {
0N/A line-height:1.5em;
0N/A margin-top:0.5em; margin-bottom:1.0em;
0N/A }
0N/A h1 {
0N/A margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
0N/A }
0N/A h2 {
0N/A margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
0N/A }
0N/A h3 {
0N/A margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
0N/A }
0N/A h4 {
0N/A margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
0N/A }
0N/A h5 {
0N/A margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
0N/A }
0N/A h6 {
0N/A margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
0N/A }
0N/A .Error {
0N/A font-weight:bold; color:red;
0N/A }
0N/A .Failure {
0N/A font-weight:bold; color:purple;
0N/A }
0N/A .Properties {
0N/A text-align:right;
0N/A }
0N/A </style>
0N/A <script type="text/javascript" language="JavaScript">
0N/A var TestCases = new Array();
0N/A var cur;
809N/A <xsl:for-each select="/testsuite">
0N/A <xsl:apply-templates select="properties"/>
0N/A </xsl:for-each>
0N/A
0N/A </script>
0N/A <script type="text/javascript" language="JavaScript"><![CDATA[
0N/A function displayProperties (name) {
0N/A var win = window.open('','JUnitSystemProperties','scrollbars=1,resizable=1');
809N/A var doc = win.document;
809N/A doc.open();
0N/A doc.write("<html><head><title>Properties of " + name + "</title>");
0N/A doc.write("<style>")
0N/A doc.write("body {font:normal 68% verdana,arial,helvetica; color:#000000; }");
0N/A doc.write("table tr td, table tr th { font-size: 68%; }");
0N/A doc.write("table.properties { border-collapse:collapse; border-left:solid 1 #cccccc; border-top:solid 1 #cccccc; padding:5px; }");
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 doc.write("</style>");
0N/A doc.write("</head><body>");
0N/A doc.write("<h3>Properties of " + name + "</h3>");
0N/A doc.write("<div align=\"right\"><a href=\"javascript:window.close();\">Close</a></div>");
0N/A doc.write("<table class='properties'>");
0N/A doc.write("<tr><th>Name</th><th>Value</th></tr>");
0N/A for (prop in TestCases[name]) {
0N/A doc.write("<tr><th>" + prop + "</th><td>" + TestCases[name][prop] + "</td></tr>");
0N/A }
0N/A doc.write("</table>");
0N/A doc.write("</body></html>");
0N/A doc.close();
0N/A win.focus();
0N/A }
809N/A ]]>
0N/A </script>
0N/A </head>
0N/A <body>
0N/A <a name="top"></a>
809N/A <xsl:call-template name="pageHeader"/>
809N/A
0N/A <!-- Summary part -->
0N/A <xsl:call-template name="summary"/>
0N/A <hr size="1" width="95%" align="left"/>
809N/A
0N/A <!-- Package List part -->
0N/A <xsl:call-template name="packagelist"/>
0N/A <hr size="1" width="95%" align="left"/>
809N/A
0N/A <!-- For each package create its part -->
0N/A <xsl:call-template name="packages"/>
0N/A <hr size="1" width="95%" align="left"/>
809N/A
0N/A <!-- For each class create the part -->
0N/A <xsl:call-template name="classes"/>
809N/A
0N/A </body>
0N/A </html>
0N/A</xsl:template>
809N/A
809N/A
809N/A
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 <h2>Packages</h2>
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 <xsl:call-template name="testsuite.test.header"/>
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="testsuites-in-package" select="/testsuites/testsuite[./@package = current()/@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)"/>
809N/A
0N/A <!-- write a summary for the package -->
0N/A <tr valign="top">
0N/A <!-- set a nice color depending if there is an error/failure -->
0N/A <xsl:attribute name="class">
0N/A <xsl:choose>
0N/A <xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
0N/A <xsl:when test="$errorCount &gt; 0">Error</xsl:when>
0N/A </xsl:choose>
0N/A </xsl:attribute>
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 <td>
0N/A <xsl:call-template name="display-time">
0N/A <xsl:with-param name="value" select="$timeCount"/>
0N/A </xsl:call-template>
0N/A </td>
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 </tr>
0N/A </xsl:for-each>
809N/A </table>
0N/A </xsl:template>
809N/A
809N/A
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:for-each select="/testsuites/testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
0N/A <xsl:sort select="@package"/>
0N/A <a name="{@package}"></a>
0N/A <h3>Package <xsl:value-of select="@package"/></h3>
809N/A
0N/A <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
0N/A <xsl:call-template name="testsuite.test.header"/>
809N/A
0N/A <!-- match the testsuites of this package -->
0N/A <xsl:apply-templates select="/testsuites/testsuite[./@package = current()/@package]" mode="print.test"/>
0N/A </table>
0N/A <a href="#top">Back to top</a>
0N/A <p/>
0N/A <p/>
0N/A </xsl:for-each>
0N/A </xsl:template>
809N/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>
809N/A
0N/A <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
0N/A <xsl:call-template name="testcase.test.header"/>
0N/A <!--
0N/A test can even not be started at all (failure to load the class)
0N/A so report the error directly
0N/A -->
0N/A <xsl:if test="/error">
0N/A <tr class="Error">
0N/A <td colspan="4"><xsl:apply-templates select="/error"/></td>
0N/A </tr>
0N/A </xsl:if>
0N/A <xsl:apply-templates select="/testcase" mode="print.test"/>
0N/A </table>
0N/A <div class="Properties">
0N/A <a>
0N/A <xsl:attribute name="href">javascript:displayProperties('<xsl:value-of select="@package"/>.<xsl:value-of select="@name"/>');</xsl:attribute>
0N/A Properties &#187;
0N/A </a>
0N/A </div>
0N/A <p/>
809N/A
0N/A <a href="#top">Back to top</a>
0N/A </xsl:for-each>
0N/A </xsl:template>
809N/A
0N/A <xsl:template name="summary">
0N/A <h2>Summary</h2>
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 <tr valign="top">
0N/A <th>Tests</th>
0N/A <th>Failures</th>
0N/A <th>Errors</th>
0N/A <th>Success rate</th>
0N/A <th>Time</th>
0N/A </tr>
0N/A <tr valign="top">
0N/A <xsl:attribute name="class">
0N/A <xsl:choose>
0N/A <xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
0N/A <xsl:when test="$errorCount &gt; 0">Error</xsl:when>
0N/A </xsl:choose>
0N/A </xsl:attribute>
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 <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 </td>
0N/A <td>
0N/A <xsl:call-template name="display-time">
0N/A <xsl:with-param name="value" select="$timeCount"/>
0N/A </xsl:call-template>
0N/A </td>
0N/A
0N/A </tr>
0N/A </table>
0N/A <table border="0" width="95%">
0N/A <tr>
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 </td>
0N/A </tr>
0N/A </table>
0N/A </xsl:template>
809N/A
0N/A <!--
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 -->
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:for-each>
0N/A </xsl:template>
809N/A
0N/A<!-- Page HEADER -->
0N/A<xsl:template name="pageHeader">
5713N/A <h1><xsl:value-of select="$TITLE"/></h1>
0N/A <table width="100%">
0N/A <tr>
0N/A <td align="left"></td>
809N/A <td align="right">Designed for use with <a href='http://www.junit.org'>JUnit</a> and <a href='http://ant.apache.org/ant'>Ant</a>.</td>
0N/A </tr>
0N/A </table>
0N/A <hr size="1"/>
0N/A</xsl:template>
0N/A
0N/A<xsl:template match="testsuite" mode="header">
0N/A <tr valign="top">
0N/A <th width="80%">Name</th>
0N/A <th>Tests</th>
0N/A <th>Errors</th>
0N/A <th>Failures</th>
0N/A <th nowrap="nowrap">Time(s)</th>
0N/A </tr>
0N/A</xsl:template>
0N/A
0N/A<!-- class header -->
0N/A<xsl:template name="testsuite.test.header">
0N/A <tr valign="top">
0N/A <th width="80%">Name</th>
0N/A <th>Tests</th>
0N/A <th>Errors</th>
0N/A <th>Failures</th>
0N/A <th nowrap="nowrap">Time(s)</th>
809N/A <th nowrap="nowrap">Time Stamp</th>
809N/A <th>Host</th>
0N/A </tr>
0N/A</xsl:template>
0N/A
0N/A<!-- method header -->
0N/A<xsl:template name="testcase.test.header">
0N/A <tr valign="top">
0N/A <th>Name</th>
0N/A <th>Status</th>
0N/A <th width="80%">Type</th>
0N/A <th nowrap="nowrap">Time(s)</th>
0N/A </tr>
0N/A</xsl:template>
0N/A
0N/A
0N/A<!-- class information -->
0N/A<xsl:template match="testsuite" mode="print.test">
0N/A <tr valign="top">
0N/A <!-- set a nice color depending if there is an error/failure -->
0N/A <xsl:attribute name="class">
0N/A <xsl:choose>
0N/A <xsl:when test="@failures[.&gt; 0]">Failure</xsl:when>
0N/A <xsl:when test="@errors[.&gt; 0]">Error</xsl:when>
0N/A </xsl:choose>
0N/A </xsl:attribute>
809N/A
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 <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 </td>
809N/A <td><xsl:apply-templates select="@timestamp"/></td>
809N/A <td><xsl:apply-templates select="@hostname"/></td>
0N/A </tr>
0N/A</xsl:template>
0N/A
0N/A<xsl:template match="testcase" mode="print.test">
0N/A <tr valign="top">
0N/A <xsl:attribute name="class">
0N/A <xsl:choose>
0N/A <xsl:when test="failure | error">Error</xsl:when>
0N/A </xsl:choose>
0N/A </xsl:attribute>
0N/A <td><xsl:value-of select="@name"/></td>
0N/A <xsl:choose>
0N/A <xsl:when test="failure">
0N/A <td>Failure</td>
0N/A <td><xsl:apply-templates select="failure"/></td>
0N/A </xsl:when>
0N/A <xsl:when test="error">
0N/A <td>Error</td>
0N/A <td><xsl:apply-templates select="error"/></td>
0N/A </xsl:when>
0N/A <xsl:otherwise>
0N/A <td>Success</td>
0N/A <td></td>
0N/A </xsl:otherwise>
0N/A </xsl:choose>
0N/A <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 </td>
0N/A </tr>
0N/A</xsl:template>
0N/A
0N/A
0N/A<xsl:template match="failure">
0N/A <xsl:call-template name="display-failures"/>
0N/A</xsl:template>
0N/A
0N/A<xsl:template match="error">
0N/A <xsl:call-template name="display-failures"/>
0N/A</xsl:template>
0N/A
0N/A<!-- Style for the error and failure in the tescase template -->
0N/A<xsl:template name="display-failures">
0N/A <xsl:choose>
0N/A <xsl:when test="not(@message)">N/A</xsl:when>
0N/A <xsl:otherwise>
0N/A <xsl:value-of select="@message"/>
0N/A </xsl:otherwise>
0N/A </xsl:choose>
0N/A <!-- display the stacktrace -->
0N/A <code>
0N/A <br/><br/>
0N/A <xsl:call-template name="br-replace">
0N/A <xsl:with-param name="word" select="."/>
0N/A </xsl:call-template>
0N/A </code>
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>
0N/A
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),&quot;'&quot;,&quot;\&apos;&quot;)"/>
0N/A <xsl:value-of select="$tmp2"/>
0N/A</xsl:template>
0N/A
0N/A
0N/A<!--
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-->
0N/A<xsl:template name="br-replace">
0N/A <xsl:param name="word"/>
5713N/A <xsl:choose>
5713N/A <xsl:when test="contains($word, '&#xa;')">
5713N/A <xsl:value-of select="substring-before($word, '&#xa;')"/>
5713N/A <br/>
5713N/A <xsl:call-template name="br-replace">
5713N/A <xsl:with-param name="word" select="substring-after($word, '&#xa;')"/>
5713N/A </xsl:call-template>
5713N/A </xsl:when>
5713N/A <xsl:otherwise>
5713N/A <xsl:value-of select="$word"/>
5713N/A </xsl:otherwise>
5713N/A </xsl:choose>
0N/A</xsl:template>
0N/A
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>
0N/A
0N/A<xsl:template name="display-percent">
0N/A <xsl:param name="value"/>
0N/A <xsl:value-of select="format-number($value,'0.00%')"/>
0N/A</xsl:template>
0N/A
0N/A</xsl:stylesheet>