The XSL changes for the Stephane's JUnitReport patch
Submitted by: Stephane Bailliez <sbailliez@imediation.com>
git-svn-id: https://svn.apache.org/repos/asf/ant/core/branches/ANT_13_BRANCH@268746 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/build.xml b/build.xml
index d004032..ad669ad 100644
--- a/build.xml
+++ b/build.xml
@@ -14,7 +14,7 @@
<property name="Name" value="Ant"/>
<property name="name" value="ant"/>
- <property name="version" value="1.3beta3"/>
+ <property name="version" value="1.3"/>
<property name="debug" value="false" />
<property name="deprecation" value="false" />
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/all-classes.xsl b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/all-classes.xsl
index 25c03dc..d4c80a2 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/all-classes.xsl
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/all-classes.xsl
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!-- This style sheet should contain just a named templates that used in the other specific templates -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="toolkit.xsl"/>
+<!--
+ Display the whole list of testsuite
+-->
<xsl:template match="testsuites">
<HTML>
<HEAD>
@@ -23,6 +24,10 @@
</HTML>
</xsl:template>
+<!--
+ Display each testsuite name with an hyperlink to the package frame.
+ The hyperlink is made of the {packagename} + {classname} + "-details.html"
+-->
<xsl:template match="testsuite">
<tr>
<td nowrap="nowrap">
@@ -37,4 +42,4 @@
</tr>
</xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/all-packages.xsl b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/all-packages.xsl
index 983d53a..b390357 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/all-packages.xsl
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/all-packages.xsl
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!-- This style sheet should contain just a named templates that used in the other specific templates -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<!-- import the commun templates -->
<xsl:include href="toolkit.xsl"/>
<xsl:template match="testsuites">
@@ -39,4 +36,4 @@
</tr>
</xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/class-details.xsl b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/class-details.xsl
index 520ddae..b4ccdd4 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/class-details.xsl
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/class-details.xsl
@@ -34,4 +34,4 @@
</HTML>
</xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/classes-list.xsl b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/classes-list.xsl
index 49b0280..058b756 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/classes-list.xsl
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/classes-list.xsl
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!-- This style sheet should contain just a named templates that used in the other specific templates -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- import the commun templates -->
@@ -43,4 +41,4 @@
</tr>
</xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/overview-packages.xsl b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/overview-packages.xsl
index 6b08620..98764ef 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/overview-packages.xsl
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/overview-packages.xsl
@@ -1,17 +1,8 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!-- This style sheet should contain just a named templates that used in the other specific templates -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="toolkit.xsl"/>
-<!-- Calculate all summary values -->
-<xsl:variable name="testCount" select="sum(//testsuite/@tests)"/>
-<xsl:variable name="errorCount" select="sum(//testsuite/@errors)"/>
-<xsl:variable name="failureCount" select="sum(//testsuite/@failures)"/>
-<xsl:variable name="timeCount" select="sum(//testsuite/@time)"/>
-<xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/>
-
<xsl:template match="testsuites">
<HTML>
<HEAD>
@@ -59,8 +50,18 @@
<xsl:template match="testsuite" mode="package">
<xsl:variable name="isError" select="(sum(//testsuite[@package = current()/@package]/@errors) + sum(//testsuite[@package = current()/@package]/@failures))>0"/>
<!-- write a summary for the package -->
- <tr bgcolor="#EEEEE" valign="top">
- <td><xsl:if test="$isError"><xsl:attribute name="class">Error</xsl:attribute></xsl:if><a href="{translate(@package,'.','/')}/package-summary.html"><xsl:value-of select="@package"/></a></td>
+ <tr valign="top">
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="$isError">Failure</xsl:when>
+ <xsl:otherwise>Pass</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <td>
+ <a href="{translate(@package,'.','/')}/package-summary.html">
+ <xsl:value-of select="@package"/>
+ </a>
+ </td>
<xsl:call-template name="statistics">
<xsl:with-param name="isError" select="$isError"/>
</xsl:call-template>
@@ -70,8 +71,19 @@
<xsl:template match="testsuite" mode="class">
<xsl:variable name="isError" select="(@errors + @failures)>0"/>
<!-- write a summary for the package -->
- <tr bgcolor="#EEEEE" valign="top">
- <td><xsl:if test="$isError"><xsl:attribute name="class">Error</xsl:attribute></xsl:if><a href="{translate(@package,'.','/')}/summary.html"><xsl:value-of select="@name"/></a></td>
+ <tr valign="top">
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="$isError">Failure</xsl:when>
+ <xsl:otherwise>Pass</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <td>
+
+ <a href="{translate(@package,'.','/')}/summary.html">
+ <xsl:value-of select="@name"/>
+ </a>
+ </td>
<xsl:call-template name="statistics">
<xsl:with-param name="isError" select="$isError"/>
</xsl:call-template>
@@ -81,10 +93,17 @@
<xsl:template name="statistics">
<xsl:variable name="isError"/>
- <td><xsl:if test="$isError"><xsl:attribute name="class">Error</xsl:attribute></xsl:if><xsl:value-of select="sum(//testsuite[@package = current()/@package]/@tests)"/></td>
- <td><xsl:if test="$isError"><xsl:attribute name="class">Error</xsl:attribute></xsl:if><xsl:value-of select="sum(//testsuite[@package = current()/@package]/@errors)"/></td>
- <td><xsl:if test="$isError"><xsl:attribute name="class">Error</xsl:attribute></xsl:if><xsl:value-of select="sum(//testsuite[@package = current()/@package]/@failures)"/></td>
- <td><xsl:if test="$isError"><xsl:attribute name="class">Error</xsl:attribute></xsl:if><xsl:value-of select="format-number(sum(//testsuite[@package = current()/@package]/@time),'#,###0.000')"/></td>
+ <td>
+ <xsl:value-of select="sum(//testsuite[@package = current()/@package]/@tests)"/></td>
+ <td>
+ <xsl:value-of select="sum(//testsuite[@package = current()/@package]/@errors)"/></td>
+ <td>
+ <xsl:value-of select="sum(//testsuite[@package = current()/@package]/@failures)"/></td>
+ <td>
+ <xsl:call-template name="display-time">
+ <xsl:with-param name="value" select="sum(//testsuite[@package = current()/@package]/@time)"/>
+ </xsl:call-template>
+ </td>
</xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/overview-summary.xsl b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/overview-summary.xsl
index c9e80a3..513be7d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/overview-summary.xsl
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/overview-summary.xsl
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:html="http://www.w3.org/Profiles/XHTML-transitional">
<xsl:include href="toolkit.xsl"/>
@@ -43,13 +42,16 @@
}
H6 {
MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica
- }
- .Error {
- font-weight:bold; color:red;
- }
- .Failure {
- font-weight:bold; color:purple;
- }
+ }
+ .Error {
+ font-weight:bold; background:#EEEEE0; color:purple;
+ }
+ .Failure {
+ font-weight:bold; background:#EEEEE0; color:red;
+ }
+ .Pass {
+ background:#EEEEE0;
+ }
</style>
</HEAD>
<body text="#000000" bgColor="#ffffff">
@@ -95,19 +97,24 @@
<xsl:variable name="timeCount" select="sum(../testsuite[./@package = current()/@package]/@time)"/>
<!-- write a summary for the package -->
- <tr bgcolor="#EEEEE" valign="top">
+ <tr valign="top">
<!-- set a nice color depending if there is an error/failure -->
<xsl:attribute name="class">
<xsl:choose>
+ <xsl:when test="$failureCount > 0">Failure</xsl:when>
<xsl:when test="$errorCount > 0">Error</xsl:when>
- <xsl:when test="$failureCount > 0">Failure</xsl:when>
+ <xsl:otherwise>Pass</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<td><a href="#{@package}"><xsl:value-of select="@package"/></a></td>
<td><xsl:value-of select="$testCount"/></td>
<td><xsl:value-of select="$errorCount"/></td>
<td><xsl:value-of select="$failureCount"/></td>
- <td><xsl:value-of select="format-number($timeCount,'#,###0.000')"/></td>
+ <td>
+ <xsl:call-template name="display-time">
+ <xsl:with-param name="value" select="$timeCount"/>
+ </xsl:call-template>
+ </td>
</tr>
</xsl:for-each>
</table>
@@ -145,12 +152,13 @@
<!-- It must match the table definition at the package level -->
<!-- ================================================================== -->
<xsl:template match="testsuite">
- <tr bgcolor="#EEEEE" valign="top">
+ <tr valign="top">
<!-- set a nice color depending if there is an error/failure -->
<xsl:attribute name="class">
<xsl:choose>
+ <xsl:when test="@failures[.> 0]">Failure</xsl:when>
<xsl:when test="@errors[.> 0]">Error</xsl:when>
- <xsl:when test="@failures[.> 0]">Failure</xsl:when>
+ <xsl:otherwise>Pass</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
@@ -159,7 +167,11 @@
<td><xsl:value-of select="@tests"/></td>
<td><xsl:value-of select="@errors"/></td>
<td><xsl:value-of select="@failures"/></td>
- <td><xsl:value-of select="format-number(@time,'#,###0.000')"/></td>
+ <td>
+ <xsl:call-template name="display-time">
+ <xsl:with-param name="value" select="@time"/>
+ </xsl:call-template>
+ </td>
</tr>
</xsl:template>
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/package-summary.xsl b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/package-summary.xsl
index 9cef8f6..87ee222 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/package-summary.xsl
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/package-summary.xsl
@@ -1,6 +1,4 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!-- This style sheet should contain just a named templates that used in the other specific templates -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- import the commun templates -->
@@ -26,7 +24,16 @@
<xsl:call-template name="packageSummaryHeader"/>
<!-- write a summary for the package -->
- <tr bgcolor="#EEEEE" valign="top">
+ <tr valign="top">
+ <xsl:variable name="errorCount" select="sum(testsuite/@errors)"/>
+ <xsl:variable name="failureCount" select="sum(testsuite/@failures)"/>
+ <xsl:attribute name="class">
+ <xsl:choose>
+ <xsl:when test="$failureCount > 0">Failure</xsl:when>
+ <xsl:when test="$errorCount > 0">Error</xsl:when>
+ <xsl:otherwise>Pass</xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
<td><xsl:value-of select="testsuite/@package"/></td>
<td><xsl:value-of select="sum(testsuite/@tests)"/></td>
<td><xsl:value-of select="sum(testsuite/@errors)"/></td>
@@ -52,12 +59,13 @@
</xsl:template>
<xsl:template match="testsuite">
- <tr bgcolor="#EEEEE" valign="top">
+ <tr valign="top">
<!-- set a nice color depending if there is an error/failure -->
<xsl:attribute name="class">
<xsl:choose>
+ <xsl:when test="@failures[.> 0]">Failure</xsl:when>
<xsl:when test="@errors[.> 0]">Error</xsl:when>
- <xsl:when test="@failures[.> 0]">Failure</xsl:when>
+ <xsl:otherwise>Pass</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
@@ -66,8 +74,12 @@
<td><xsl:value-of select="@tests"/></td>
<td><xsl:value-of select="@errors"/></td>
<td><xsl:value-of select="@failures"/></td>
- <td><xsl:value-of select="format-number(@time,'#,###0.000')"/></td>
+ <td>
+ <xsl:call-template name="display-time">
+ <xsl:with-param name="value" select="@time"/>
+ </xsl:call-template>
+ </td>
</tr>
</xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/toolkit.xsl b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/toolkit.xsl
index a52103a..c81a169 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/toolkit.xsl
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/xsl/toolkit.xsl
@@ -1,9 +1,28 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<!-- This style sheet should contain just a named templates that used in the other specific templates -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<!-- transform string like a.b.c to ../../../ -->
+<!--
+ format a number in to display its value in percent
+ @param value the number to format
+-->
+<xsl:template name="display-time">
+ <xsl:param name="value"/>
+ <xsl:value-of select="format-number($value,'0.000')"/>
+</xsl:template>
+
+<!--
+ format a number in to display its value in percent
+ @param value the number to format
+-->
+<xsl:template name="display-percent">
+ <xsl:param name="value"/>
+ <xsl:value-of select="format-number($value,'0.00%')"/>
+</xsl:template>
+
+<!--
+ transform string like a.b.c to ../../../
+ @param path the path to transform into a descending directory path
+-->
<xsl:template name="path">
<xsl:param name="path"/>
<xsl:if test="contains($path,'.')">
@@ -119,18 +138,27 @@
<xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/>
<table border="0" cellpadding="5" cellspacing="2" width="95%">
<xsl:call-template name="summaryHeader"/>
- <tr bgcolor="#EEEEE" valign="top">
+ <tr valign="top">
<xsl:attribute name="class">
- <xsl:choose>
- <xsl:when test="./failure | ./error">Error</xsl:when>
- <xsl:otherwise>TableRowColor</xsl:otherwise>
- </xsl:choose>
+ <xsl:choose>
+ <xsl:when test="$failureCount > 0">Failure</xsl:when>
+ <xsl:when test="$errorCount > 0">Error</xsl:when>
+ <xsl:otherwise>Pass</xsl:otherwise>
+ </xsl:choose>
</xsl:attribute>
<td><xsl:value-of select="$testCount"/></td>
<td><xsl:value-of select="$failureCount"/></td>
<td><xsl:value-of select="$errorCount"/></td>
- <td><xsl:value-of select="format-number($successRate,'#,##0.00%')"/></td>
- <td><xsl:value-of select="format-number($timeCount,'#,###0.000')"/></td>
+ <td>
+ <xsl:call-template name="display-percent">
+ <xsl:with-param name="value" select="$successRate"/>
+ </xsl:call-template>
+ </td>
+ <td>
+ <xsl:call-template name="display-time">
+ <xsl:with-param name="value" select="$timeCount"/>
+ </xsl:call-template>
+ </td>
</tr>
</table>
Note: <i>failures</i> are anticipated and checked for with assertions while <i>errors</i> are unanticipated.
@@ -142,10 +170,12 @@
=====================================================================
-->
<xsl:template match="testcase">
- <TR bgcolor="#EEEEE" valign="top"><xsl:attribute name="class">
+ <TR valign="top">
+ <xsl:attribute name="class">
<xsl:choose>
- <xsl:when test="./failure | ./error">Error</xsl:when>
- <xsl:otherwise>TableRowColor</xsl:otherwise>
+ <xsl:when test="./failure">Failure</xsl:when>
+ <xsl:when test="./error">Error</xsl:when>
+ <xsl:otherwise>Pass</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<TD><xsl:value-of select="./@name"/></TD>
@@ -160,10 +190,14 @@
</xsl:when>
<xsl:otherwise>
<TD>Success</TD>
- <TD></TD>
+ <TD><xsl:apply-templates select="./pass"/></TD>
</xsl:otherwise>
</xsl:choose>
- <td><xsl:value-of select="format-number(@time,'#,###0.000')"/></td>
+ <td>
+ <xsl:call-template name="display-time">
+ <xsl:with-param name="value" select="@time"/>
+ </xsl:call-template>
+ </td>
</TR>
</xsl:template>
@@ -201,4 +235,4 @@
<xsl:apply-templates/>
</xsl:template>
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>