Hi all,
I've noticed tah the XSL stylesheets for the nunitReport does not work with the xml output of the Nunit2 task.Attached is a stylesheet effectively showing the reports detail.
Note that I,ve included the "toolkit.xsl" inside de NunitSummary.xsl
Yves
<?xml version="1.0" encoding="ISO-8859-1" ?> <!-- This XSL File is based on the summary_overview.xsl template created by Erik Hatcher fot Ant's JUnitReport. Modified by Tomas Restrepo ([EMAIL PROTECTED]) for use with NUnitReport --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:html="http://www.w3.org/Profiles/XHTML-transitional"> <xsl:output method="html" indent="yes" /> <!-- ==================================================== Create the page structure ==================================================== --> <xsl:template match="test-results"> <HTML> <HEAD> <!-- put the style in the html so that we can mail it w/o problem --> <style type="text/css"> BODY { font: normal verdana, arial, helvetica; color:#000000; } TD { font: normal } P { line-height:1.5em; margin-top:0.5em; margin-bottom:1.0em; } H1 { MARGIN: 0px 0px 5px; FONT: bold large arial, verdana, helvetica; } H2 { MARGIN-TOP: 1em; MARGIN-BOTTOM: 0.5em; FONT: bold larger verdana,arial,helvetica } H3 { MARGIN-BOTTOM: 0.5em; FONT: bold 13px verdana,arial,helvetica } H4 { MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica } H5 { MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica } H6 { MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica } .Error { font-weight:bold; background:#EEEEE0; color:purple; } .Failure { font-weight:bold; background:#b22222; color: #ffffff; } .ClassName { font-weight:bold; padding-left: 18px; cursor: hand; color: #777; } .TestClassDetails { width: 95%; margin-bottom: 10px; border-bottom: 1px dotted #999; } .FailureDetail { font-size: -1; padding-left: 2.0em; border: 1px solid #999; } .Pass { background: #90ee90; } .NotRun { background:#ffd700; } .DetailTable TD { padding-top: 1px; padding-bottom: 1px; padding-left: 3px; padding-right: 3px; } .TableHeader { background: #6699cc; color: white; font-weight: bold; horizontal-align: center; } .EnvInfoHeader { background: #ff0000; color: white; font-weight: bold; horizontal-align: center; } .EnvInfoRow { background:#EEEEE0 } .AFailure { color: #ffffff; } </style> <script language="JavaScript"><![CDATA[ function toggle (field) { field.style.display = (field.style.display == "block") ? "none" : "block"; } ]]> </script> </HEAD> <body text="#000000" bgColor="#ffffff"> <a name="#top"></a> <xsl:call-template name="header" /> <!-- Summary part --> <xsl:call-template name="summary" /> <hr size="1" width="95%" align="left" /> <!-- Package List part --> <xsl:call-template name="packagelist" /> <hr size="1" width="95%" align="left" /> <!-- For each testsuite create the part --> <xsl:apply-templates select="test-suite"> <xsl:sort select="@name" /> </xsl:apply-templates> <!-- Environment info part --> <xsl:call-template name="envinfo" /> </body> </HTML> </xsl:template> <!-- ================================================================== --> <!-- Write a list of all packages with an hyperlink to the anchor of --> <!-- of the package name. --> <!-- ================================================================== --> <xsl:template name="packagelist"> <h2>TestSuite Summary</h2> <table border="0" class="DetailTable" width="95%"> <xsl:call-template name="packageSummaryHeader" /> <!-- list all packages recursively --> <xsl:for-each select="//test-suite[./results/test-suite/results/test-case]"> <!--[not(./@name = preceding-sibling::test-suite/@name)][./results/test-suite/results/test-case]"--> <xsl:sort select=".//test-case/@name" /> <xsl:variable name="testCount" select="count(.//test-case)" /> <xsl:variable name="not-runCount" select='count(.//[EMAIL PROTECTED]"False"])' /> <xsl:variable name="failureCount" select='count(.//[EMAIL PROTECTED]"False"])' /> <xsl:variable name="timeCount" select="sum(.//test-case/@time)" /> <!-- write a summary for the package --> <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:otherwise>Pass</xsl:otherwise> </xsl:choose> </xsl:attribute> <td> <a href="#{generate-id(@name)}"> <xsl:attribute name="class"> <xsl:choose> <xsl:when test="$failureCount > 0">AFailure</xsl:when> <xsl:otherwise>Pass</xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:value-of select="concat ( substring-before (.//test-case/@name, ./@name), ./@name)" /> </a> </td> <td> <xsl:value-of select="$testCount" /> </td> <td> <xsl:value-of select="$not-runCount" /> </td> <td> <xsl:value-of select="$failureCount" /> </td> <td> <xsl:call-template name="display-time"> <xsl:with-param name="value" select="$timeCount" /> </xsl:call-template> </td> </tr> </xsl:for-each> </table> </xsl:template> <!-- ================================================================== --> <!-- Write a list of all classes used in a testsuite, alongside with --> <!-- the results for each one. --> <!-- ================================================================== --> <xsl:template match="test-suite[./results/test-suite/results/test-case]"> <!-- create an anchor to this class name --> <a name="#{generate-id(@name)}"></a> <h3>TestSuite <xsl:value-of select="concat ( substring-before (./results/test-suite/results/test-case/@name, ./@name), ./@name)" /></h3> <xsl:for-each select=".//test-suite"> <xsl:variable name="thisClass"> <xsl:value-of select="./@name" /> </xsl:variable> <xsl:variable name="details"> <xsl:value-of select="generate-id(@name)" /> </xsl:variable> <div class="TestClassDetails"> <div class="ClassName" onclick="toggle({$details})"> <xsl:value-of select="@name" /> </div> <table border="0" width="90%" id="{$details}" style="display: block; margin-left: 35px" class="DetailTable"> <xsl:call-template name="classesSummaryHeader" /> <xsl:apply-templates select=".//test-case"> <[EMAIL PROTECTED]"--> <xsl:sort select="@name" /> </xsl:apply-templates> </table> </div> </xsl:for-each> <a href="#top">Back to top</a> <hr size="1" width="95%" align="left" /> </xsl:template> <xsl:template name="dot-replace"> <xsl:param name="package" /> <xsl:choose> <xsl:when test="contains($package,'.')"><xsl:value-of select="substring-before($package,'.')" />_<xsl:call-template name="dot-replace"> <xsl:with-param name="package" select="substring-after($package,'.')" /> </xsl:call-template></xsl:when> <xsl:otherwise> <xsl:value-of select="$package" /> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:param name="nant.filename" /> <xsl:param name="nant.version" /> <xsl:param name="nant.project.name" /> <xsl:param name="nant.project.buildfile" /> <xsl:param name="nant.project.basedir" /> <xsl:param name="nant.project.default" /> <xsl:param name="sys.os" /> <xsl:param name="sys.os.platform" /> <xsl:param name="sys.os.version" /> <xsl:param name="sys.clr.version" /> <!-- key used to select testcase classnames --> <xsl:key name="classnameKey" match="test-case" use="@name" /> <!-- This XSL File is based on the toolkit.xsl template created by Erik Hatcher fot Ant's JUnitReport
Modified by Tomas Restrepo ([EMAIL PROTECTED]) for use
with NUnitReport
-->
<!--
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,'.')">
<xsl:text>../</xsl:text>
<xsl:call-template name="path">
<xsl:with-param name="path">
<xsl:value-of select="substring-after($path,'.')" />
</xsl:with-param>
</xsl:call-template>
</xsl:if>
<xsl:if test="not(contains($path,'.')) and not($path = '')">
<xsl:text>../</xsl:text>
</xsl:if>
</xsl:template>
<!--
template that will convert a carriage return into a br tag
@param word the text from which to convert CR to BR tag
-->
<xsl:template name="br-replace">
<xsl:param name="word" />
<xsl:choose>
<xsl:when test="contains($word,'
')">
<xsl:value-of select="substring-before($word,'
')" />
<br />
<xsl:call-template name="br-replace">
<xsl:with-param name="word" select="substring-after($word,'
')" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$word" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
=====================================================================
classes summary header
=====================================================================
-->
<xsl:template name="header">
<xsl:param name="path" />
<h1>Unit Tests Results - <xsl:value-of select="$nant.project.name" /></h1>
<table width="100%">
<tr>
<td align="left">
Generated: <xsl:value-of select="@created" /> -
<a href="#envinfo">Environment Information</a>
</td>
<td align="right">Designed for use with
<a href='http://nunit.sourceforge.net/'>NUnit</a> and
<a href='http://nant.sourceforge.net/'>NAnt</a>.
</td>
</tr>
</table>
<hr size="1" />
</xsl:template>
<xsl:template name="summaryHeader">
<tr valign="top" class="TableHeader">
<td>
<b>Tests</b>
</td>
<td>
<b>Failures</b>
</td>
<td nowrap="nowrap">
<b>Not run</b>
</td>
<td nowrap="nowrap">
<b>Success Rate</b>
</td>
<td nowrap="nowrap">
<b>Time(s)</b>
</td>
</tr>
</xsl:template>
<!--
=====================================================================
package summary header
=====================================================================
-->
<xsl:template name="packageSummaryHeader">
<tr class="TableHeader" valign="top">
<td width="75%">
<b>Name</b>
</td>
<td width="5%">
<b>Tests</b>
</td>
<td width="5%" nowrap="nowrap">
<b>Not Run</b>
</td>
<td width="5%">
<b>Failures</b>
</td>
<td width="10%" nowrap="nowrap">
<b>Time</b>
</td>
</tr>
</xsl:template>
<!--
=====================================================================
classes summary header
=====================================================================
-->
<xsl:template name="classesSummaryHeader">
<tr class="TableHeader" valign="top" style="height: 4px">
<td width="85%">
<b>Name</b>
</td>
<td width="10%">
<b>Status</b>
</td>
<td width="5%" nowrap="nowrap">
<b>Time</b>
</td>
</tr>
</xsl:template>
<!--
=====================================================================
Write the summary report
It creates a table with computed values from the document:
User | Date | Environment | Tests | Failures | Errors | Rate | Time
Note : this template must call at the testsuites level
=====================================================================
-->
<xsl:template name="summary">
<h2>Summary</h2>
<xsl:variable name="testCount" select="count(//test-case)" />
<xsl:variable name="not-runCount" select='count(//[EMAIL PROTECTED]"False"])' />
<xsl:variable name="failureCount" select='count(//[EMAIL PROTECTED]"False"])' />
<xsl:variable name="timeCount" select="sum(//test-case/@time)" />
<xsl:variable name="successRate" select="($testCount - $failureCount ) div $testCount" />
<table border="0" class="DetailTable" width="95%">
<xsl:call-template name="summaryHeader" />
<tr valign="top">
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$failureCount > 0">Failure</xsl:when>
<xsl:when test="$not-runCount > 0">Not Run</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="$not-runCount" />
</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>
</xsl:template>
<!--
=====================================================================
testcase report
=====================================================================
-->
<xsl:template match="test-case">
<xsl:variable name="result">
<xsl:choose>
<xsl:when test='./@success="False"'>Failure</xsl:when>
<xsl:when test='./@executed="False"'>NotRun</xsl:when>
<xsl:when test='./@success="True"'>Pass</xsl:when>
<xsl:otherwise>N/A</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="newid" select="generate-id(@name)" />
<TR valign="top">
<xsl:attribute name="class">
<xsl:value-of select="$result" />
</xsl:attribute>
<xsl:if test="$result != "Pass"">
<xsl:attribute name="onclick">javascript:toggle(<xsl:value-of select="$newid" />)</xsl:attribute>
<xsl:attribute name="style">cursor: hand;</xsl:attribute>
</xsl:if>
<TD>
<xsl:value-of select="substring-after(./@name, concat(../../@name,'.'))" />
</TD>
<td>
<xsl:value-of select="$result" />
</td>
<td>
<xsl:call-template name="display-time">
<xsl:with-param name="value" select="@time" />
</xsl:call-template>
</td>
</TR>
<xsl:if test="$result != "Pass"">
<tr style="display: block;">
<xsl:attribute name="id">
<xsl:value-of select="$newid" />
</xsl:attribute>
<td colspan="3" class="FailureDetail">
<xsl:apply-templates select="./failure" />
<xsl:apply-templates select="./reason" />
</td>
</tr>
</xsl:if>
</xsl:template>
<!-- Note : the below template error and failure are the same style
so just call the same style store in the toolkit template -->
<xsl:template match="failure">
<xsl:call-template name="display-failures" />
</xsl:template>
<xsl:template match="reason">
<xsl:call-template name="display-failures" />
</xsl:template>
<!-- Style for the error and failure in the tescase template -->
<xsl:template name="display-failures">
<code>
<xsl:choose>
<xsl:when test="not(./message)">N/A</xsl:when>
<xsl:otherwise>
<xsl:value-of select="./message" />
</xsl:otherwise>
</xsl:choose>
<!-- display the stacktrace -->
<p />
<xsl:call-template name="br-replace">
<xsl:with-param name="word" select="./stack-trace" />
</xsl:call-template>
</code>
<!-- the later is better but might be problematic for non-21" monitors... -->
<!--pre><xsl:value-of select="."/></pre-->
</xsl:template>
<!--
=====================================================================
Environtment Info Report
=====================================================================
-->
<xsl:template name="envinfo">
<a name="envinfo"></a>
<h2>Environment Information</h2>
<table border="0" class="DetailTable" width="95%">
<tr class="EnvInfoHeader">
<td>Property</td>
<td>Value</td>
</tr>
<tr class="EnvInfoRow">
<td>NAnt Location</td>
<td>
<xsl:value-of select="$nant.filename" />
</td>
</tr>
<tr class="EnvInfoRow">
<td>NAnt Version</td>
<td>
<xsl:value-of select="$nant.version" />
</td>
</tr>
<tr class="EnvInfoRow">
<td>Buildfile</td>
<td>
<xsl:value-of select="$nant.project.buildfile" />
</td>
</tr>
<tr class="EnvInfoRow">
<td>Base Directory</td>
<td>
<xsl:value-of select="$nant.project.basedir" />
</td>
</tr>
<tr class="EnvInfoRow">
<td>Operating System</td>
<td>
<xsl:value-of select="$sys.os.platform" />
</td>
<!--
If this doesn't look right, your version of NAnt
has a broken sysinfo task..
<td><xsl:value-of select="$sys.os.platform"/> - <xsl:value-of select="$sys.os.version"/></td>
or
<td><xsl:value-of select="$sys.os.version"/></td>
-->
</tr>
<tr class="EnvInfoRow">
<td>.NET CLR Version</td>
<td>
<xsl:value-of select="$sys.clr.version" />
</td>
</tr>
</table>
<a href="#top">Back to top</a>
</xsl:template>
<!-- I am sure that all nodes are called -->
<xsl:template match="*">
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>

