diff --git a/src/Transforms/DefaultTransform-v3.xslt b/src/Transforms/DefaultTransform-v3.xslt index 6051b23..7832df5 100644 --- a/src/Transforms/DefaultTransform-v3.xslt +++ b/src/Transforms/DefaultTransform-v3.xslt @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> - <xsl:output method='text'/> + <xsl:output method="text"/> <xsl:template match="/"> <xsl:apply-templates/> </xsl:template> @@ -14,6 +14,10 @@ </xsl:variable> <xsl:template match="test-run"> + + <!-- Command Line --> + <xsl:value-of select="concat('Command Line ', $newline)"/> + <xsl:value-of select="concat(command-line, $break)"/> <!-- Runtime Environment --> <xsl:value-of select="concat('Runtime Environment ', $newline)"/> diff --git a/src/Transforms/HtmlSummary-v3.xslt b/src/Transforms/HtmlSummary-v3.xslt index 4971b71..61ffbf8 100644 --- a/src/Transforms/HtmlSummary-v3.xslt +++ b/src/Transforms/HtmlSummary-v3.xslt @@ -1,109 +1,98 @@ <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:preserve-space elements="*" /> - <xsl:output omit-xml-declaration="yes" method="html" indent="yes" encoding="UTF-8" /> + <xsl:output omit-xml-declaration="yes" indent="yes" encoding="UTF-8" /> <xsl:template match="/"> <style type="text/css"> - * { - font-family: "Times New Roman", Times, serif; - } + .strong { font-weight: bold; } - </style> - <xsl:apply-templates/> - - </xsl:template> - <xsl:template match="test-run"> - - <!-- Runtime Environment --> - <div id="runtime"> - <span class="strong">Runtime Environment </span> + .smllabel { + width:110px; + font-weight: bold; + } - <br /> - <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> - <span class="strong">OS Version: </span> + td.left { + text-align: left; + } - <span> - <xsl:value-of select="test-suite/environment/@os-version[1]"/> - </span> - <br/> - <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> - <span class="strong"> CLR Version: </span> + td.right { + text-align: right; + } - <span> - <xsl:value-of select="@clr-version"/> - </span> - <br/> - <br/> + li { + font-family: monospace + } + .collapsed + { + border:0; + border-collapse: collapse; + } - <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> - <span class="strong"> - NUnit Version: - </span> + </style> + <xsl:apply-templates/> - <span> - <xsl:value-of select="@engine-version"/> - </span> - <br/> - </div> - <br/> + </xsl:template> - <!-- Test Summary--> - <div id="testsummary"> - <span class="strong">Test Run Summary</span> - <br/> - <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> - <span class="strong"> Overall result: </span> - <span> - <xsl:value-of select="@result"/> - </span> - <br/> - <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> + <xsl:template match="test-run"> - <span class="strong"> Test Count: </span> - <span> - <xsl:value-of select="@total"/>, - </span> - <span class="strong"> Passed: </span> - <span> - <xsl:value-of select="@passed"/>, - </span> - <span class="strong"> Failed: </span> - <span> - <xsl:value-of select="@failed"/>, - </span> - <span class="strong"> Inconclusive: </span> - <span> - <xsl:value-of select="@inconclusive"/>, - </span> - <span class="strong"> Skipped: </span> - <span> - <xsl:value-of select="@skipped"/> - </span> - <br/> + <!-- Runtime Environment --> + <h4>Runtime Environment</h4> + + <table id="runtime"> + <tr> + <td class="smllabel right">OS Version:</td> + <td class="left"> + <xsl:value-of select="test-suite/environment/@os-version[1]"/> + </td> + </tr> + <tr> + <td class="smllabel right">CLR Version:</td> + <td class="left"> + <xsl:value-of select="@clr-version"/> + </td> + </tr> + <tr> + <td colspan="2"> + <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> + </td> + </tr> + <tr> + <td class="smllabel right">NUnit Version:</td> + <td class="left"> + <xsl:value-of select="@engine-version"/> + </td> + </tr> + </table> + + <h4>Test Run Summary</h4> + <table id="summary" class="collapsed"> + <tr> + <td class="smllabel right">Overall result:</td> + <td class="left"> + <xsl:value-of select="@result"/> + </td> + </tr> + <tr> + <td class="smllabel right">Test Count:</td> + <td class="left"> + <xsl:value-of select="@total"/>, Passed: <xsl:value-of select="@passed"/>, Failed: <xsl:value-of select="@failed"/>, Inconclusive: <xsl:value-of select="@inconclusive"/>, Skipped: <xsl:value-of select="@skipped"/> + </td> + </tr> <!-- [Optional] - Failed Test Summary --> <xsl:if test="@failed > 0"> <xsl:variable name="failedTotal" select="count(//test-case[@result='Failed' and not(@label)])" /> <xsl:variable name="errorsTotal" select="count(//test-case[@result='Failed' and @label='Error'])" /> <xsl:variable name="invalidTotal" select="count(//test-case[@result='Failed' and @label='Invalid'])" /> - - <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> - <span class="strong">Failed Tests - Failures: </span> - <span> - <xsl:value-of select="$failedTotal"/>, - </span> - <span class="strong"> Errors: </span> - <span> - <xsl:value-of select="$errorsTotal"/>, - </span> - <span class="strong"> Invalid: </span> - <span> - <xsl:value-of select="$invalidTotal"/> - </span> - <br/> + <tr> + <td class="smllabel right">Failed Tests: </td> + <td class="left"> + Failures: <xsl:value-of select="$failedTotal"/>, Errors: <xsl:value-of select="$errorsTotal"/>, Invalid: <xsl:value-of select="$invalidTotal"/> + </td> + </tr> </xsl:if> <!-- [Optional] - Skipped Test Summary --> @@ -111,48 +100,35 @@ <xsl:variable name="ignoredTotal" select="count(//test-case[@result='Skipped' and @label='Ignored'])" /> <xsl:variable name="explicitTotal" select="count(//test-case[@result='Skipped' and @label='Explicit'])" /> <xsl:variable name="otherTotal" select="count(//test-case[@result='Skipped' and not(@label='Explicit' or @label='Ignored')])" /> - - <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> - <span class="strong">Skipped Tests - Ignored: </span> - <span> - <xsl:value-of select="$ignoredTotal"/>, - </span> - <span class="strong"> Explicit: </span> - <span> - <xsl:value-of select="$explicitTotal"/>, - </span> - <span class="strong"> Other: </span> - <span> - <xsl:value-of select="$otherTotal"/> - </span> - - <br/> + <tr> + <td class="smllabel right">Skipped Tests: </td> + <td class="left"> + Ignored: <xsl:value-of select="$ignoredTotal"/>, Explicit: <xsl:value-of select="$explicitTotal"/>, Other: <xsl:value-of select="$otherTotal"/> + </td> + </tr> </xsl:if> <!-- Times --> - <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> - <span class="strong">Start time: </span> - <span> - <xsl:value-of select="@start-time"/> - </span> - <br/> - <xsl:text disable-output-escaping="yes"><![CDATA[  ]]></xsl:text> - <span class="strong">End time: </span> - <span> - <xsl:value-of select="@end-time"/> - </span> - <br/> - <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> - <span class="strong">Duration: </span> - <span> - <xsl:value-of select="format-number(@duration,'0.000')"/> seconds - </span> - <br/> - </div> + <tr> + <td class="smllabel right">Start time: </td> + <td class="left"> + <xsl:value-of select="@start-time"/> + </td> + </tr> + <tr> + <td class="smllabel right">End time: </td> + <td class="left"> + <xsl:value-of select="@end-time"/> + </td> + </tr> + <tr> + <td class="smllabel right">Duration: </td> + <td class="left"> + <xsl:value-of select="format-number(@duration,'0.000')"/> seconds + </td> + </tr> + </table> - - <br/> - </xsl:template> </xsl:stylesheet> diff --git a/src/Transforms/HtmlTransform-v3.xslt b/src/Transforms/HtmlTransform-v3.xslt new file mode 100644 index 0000000..f14c15d --- /dev/null +++ b/src/Transforms/HtmlTransform-v3.xslt @@ -0,0 +1,250 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:preserve-space elements="*" /> + <xsl:output omit-xml-declaration="yes" indent="yes" /> + <xsl:template match="/"> + <style type="text/css"> + + .strong { + font-weight: bold; + } + + .smllabel { + width:110px; + font-weight: bold; + } + + td.left { + text-align: left; + } + + td.right { + text-align: right; + } + + li { + font-family: monospace + } + .collapsed + { + border:0; + border-collapse: collapse; + } + + </style> + <xsl:apply-templates/> + </xsl:template> + + <xsl:template match="test-run"> + + <!-- Command Line --> + <h4>Command Line</h4> + <pre> + <xsl:value-of select="command-line"/> + </pre> + + <!-- Runtime Environment --> + <h4>Runtime Environment</h4> + + <table id="runtime"> + <tr> + <td class="smllabel right">OS Version:</td> + <td class="left"> + <xsl:value-of select="test-suite/environment/@os-version[1]"/> + </td> + </tr> + <tr> + <td class="smllabel right">CLR Version:</td> + <td class="left"> + <xsl:value-of select="@clr-version"/> + </td> + </tr> + <tr> + <td colspan="2"> + <xsl:text disable-output-escaping="yes"><![CDATA[ ]]></xsl:text> + </td> + </tr> + <tr> + <td class="smllabel right">NUnit Version:</td> + <td class="left"> + <xsl:value-of select="@engine-version"/> + </td> + </tr> + </table> + + <!-- Test Files --> + <div id="testfiles"> + <h4>Test Files</h4> + <xsl:if test="count(test-suite[@type='Assembly']) > 0"> + <ol> + <xsl:for-each select="test-suite[@type='Assembly']"> + <li> + <xsl:value-of select="@fullname"/> + </li> + </xsl:for-each> + </ol> + </xsl:if> + </div> + + <!-- Tests Not Run --> + <xsl:if test="//test-case[@result='Skipped']"> + <h4>Tests Not Run</h4> + <ol> + <xsl:apply-templates select="//test-case[@result='Skipped']"/> + </ol> + </xsl:if> + + <!-- Errors and Failures --> + <xsl:if test="//test-case[failure]"> + <h4>Errors and Failures</h4> + <ol> + <xsl:apply-templates select="//test-case[failure]"/> + </ol> + </xsl:if> + + <!-- Run Settings (gets first one found) --> + <xsl:variable name="settings" select ="//settings[1]" /> + + <h4>Run Settings</h4> + <ul> + <li> + DefaultTimeout: <xsl:value-of select="$settings/setting[@name='DefaultTimeout']/@value"/> + </li> + <li> + WorkDirectory: <xsl:value-of select="$settings/setting[@name='WorkDirectory']/@value"/> + </li> + <li> + ImageRuntimeVersion: <xsl:value-of select="$settings/setting[@name='ImageRuntimeVersion']/@value"/> + </li> + <li> + ImageTargetFrameworkName: <xsl:value-of select="$settings/setting[@name='ImageTargetFrameworkName']/@value"/> + </li> + <li> + ImageRequiresX86: <xsl:value-of select="$settings/setting[@name='ImageRequiresX86']/@value"/> + </li> + <li> + ImageRequiresDefaultAppDomainAssemblyResolver: <xsl:value-of select="$settings/setting[@name='ImageRequiresDefaultAppDomainAssemblyResolver']/@value"/> + </li> + <li> + NumberOfTestWorkers: <xsl:value-of select="$settings/setting[@name='NumberOfTestWorkers']/@value"/> + </li> + </ul> + + <h4>Test Run Summary</h4> + <table id="summary" class="collapsed"> + <tr> + <td class="smllabel right">Overall result:</td> + <td class="left"> + <xsl:value-of select="@result"/> + </td> + </tr> + <tr> + <td class="smllabel right">Test Count:</td> + <td class="left"> + <xsl:value-of select="@total"/>, Passed: <xsl:value-of select="@passed"/>, Failed: <xsl:value-of select="@failed"/>, Inconclusive: <xsl:value-of select="@inconclusive"/>, Skipped: <xsl:value-of select="@skipped"/> + </td> + </tr> + + <!-- [Optional] - Failed Test Summary --> + <xsl:if test="@failed > 0"> + <xsl:variable name="failedTotal" select="count(//test-case[@result='Failed' and not(@label)])" /> + <xsl:variable name="errorsTotal" select="count(//test-case[@result='Failed' and @label='Error'])" /> + <xsl:variable name="invalidTotal" select="count(//test-case[@result='Failed' and @label='Invalid'])" /> + <tr> + <td class="smllabel right">Failed Tests: </td> + <td class="left"> + Failures: <xsl:value-of select="$failedTotal"/>, Errors: <xsl:value-of select="$errorsTotal"/>, Invalid: <xsl:value-of select="$invalidTotal"/> + </td> + </tr> + </xsl:if> + + <!-- [Optional] - Skipped Test Summary --> + <xsl:if test="@skipped > 0"> + <xsl:variable name="ignoredTotal" select="count(//test-case[@result='Skipped' and @label='Ignored'])" /> + <xsl:variable name="explicitTotal" select="count(//test-case[@result='Skipped' and @label='Explicit'])" /> + <xsl:variable name="otherTotal" select="count(//test-case[@result='Skipped' and not(@label='Explicit' or @label='Ignored')])" /> + <tr> + <td class="smllabel right">Skipped Tests: </td> + <td class="left"> + Ignored: <xsl:value-of select="$ignoredTotal"/>, Explicit: <xsl:value-of select="$explicitTotal"/>, Other: <xsl:value-of select="$otherTotal"/> + </td> + </tr> + </xsl:if> + + <!-- Times --> + <tr> + <td class="smllabel right">Start time: </td> + <td class="left"> + <xsl:value-of select="@start-time"/> + </td> + </tr> + <tr> + <td class="smllabel right">End time: </td> + <td class="left"> + <xsl:value-of select="@end-time"/> + </td> + </tr> + <tr> + <td class="smllabel right">Duration: </td> + <td class="left"> + <xsl:value-of select="format-number(@duration,'0.000')"/> seconds + </td> + </tr> + </table> + </xsl:template> + + <xsl:template match="test-case"> + <!-- Determine type of test-case for formatting --> + <xsl:variable name="type"> + <xsl:choose> + <xsl:when test="@result='Skipped'"> + <xsl:choose> + <xsl:when test="@label='Ignored' or @label='Explicit'"> + <xsl:value-of select="@label"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="'Other'"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:when test="@result='Failed'"> + <xsl:choose> + <xsl:when test="@label='Error' or @label='Invalid'"> + <xsl:value-of select="@label"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="'Failed'"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="'Unknown'"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <!-- Show details of test-cases either skipped or errored --> + <li> + <pre> + <xsl:value-of select="concat($type,' : ', @fullname)" /> + <br/> + <xsl:value-of select="child::node()/message"/> + + <xsl:choose> + <xsl:when test="$type='Failed'"> + <br/> + </xsl:when> + <xsl:when test="$type='Error'"> + <br/> + </xsl:when> + </xsl:choose> + + <!-- Stack trace for failures --> + <xsl:if test="failure and ($type='Failed' or $type='Error')"> + <xsl:value-of select="failure/stack-trace"/> + </xsl:if> + </pre> + </li> + </xsl:template> + +</xsl:stylesheet> diff --git a/src/nunit-summary.exe.csproj b/src/nunit-summary.exe.csproj index d0f5dc5..a66daf6 100644 --- a/src/nunit-summary.exe.csproj +++ b/src/nunit-summary.exe.csproj @@ -85,6 +85,9 @@ <ItemGroup> <EmbeddedResource Include="Transforms\HtmlSummary-v3.xslt" /> </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="Transforms\HtmlTransform-v3.xslt" /> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets.