3 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform" version=
"1.0">
5 <xsl:output method=
"html"/>
7 <xsl:variable name=
"nunit2.result.list" select=
"//test-results"/>
8 <xsl:variable name=
"nunit2.testcount" select=
"sum($nunit2.result.list/@total)"/>
9 <xsl:variable name=
"nunit2.failures" select=
"sum($nunit2.result.list/@failures)"/>
10 <xsl:variable name=
"nunit2.notrun" select=
"sum($nunit2.result.list/@not-run)"/>
11 <xsl:variable name=
"nunit2.time" select=
"sum($nunit2.result.list/test-suite[position()=1]/@time)"/>
12 <xsl:variable name=
"nunit2.case.list" select=
"$nunit2.result.list//test-case"/>
13 <xsl:variable name=
"nunit2.suite.list" select=
"$nunit2.result.list//test-suite"/>
14 <xsl:variable name=
"nunit2.failure.list" select=
"$nunit2.case.list//failure"/>
15 <xsl:variable name=
"nunit2.notrun.list" select=
"$nunit2.case.list//reason"/>
17 <xsl:variable name=
"testsuite.list" select=
"/cruisecontrol/build/buildresults//testsuite"/>
18 <xsl:variable name=
"testcase.list" select=
"$testsuite.list/testcase"/>
19 <xsl:variable name=
"testcase.error.list" select=
"$testcase.list/error"/>
20 <xsl:variable name=
"testsuite.error.count" select=
"count($testcase.error.list)"/>
21 <xsl:variable name=
"testcase.failure.list" select=
"$testcase.list/failure"/>
22 <xsl:variable name=
"totalErrorsAndFailures" select=
"count($testcase.error.list) + count($testcase.failure.list) + count($nunit2.failure.list)"/>
24 <xsl:variable name=
"nunit.tests.present" select=
"count(//test-results) > 0 or count(/cruisecontrol/build/buildresults//testsuite) > 0" />
25 <xsl:variable name=
"junit.tests.present" select=
"count(//cruisecontrol//testsuite) > 0" />
27 <xsl:template match=
"/">
30 <xsl:when test=
"$nunit.tests.present">
31 <table class=
"section-table" cellpadding=
"2" cellspacing=
"0" border=
"0" width=
"98%">
35 <td class=
"sectionheader" colspan=
"2">
36 Tests run:
<xsl:value-of select=
"$nunit2.testcount"/>, Failures:
<xsl:value-of select=
"$nunit2.failures"/>, Not run:
<xsl:value-of select=
"$nunit2.notrun"/>, Time:
<xsl:value-of select=
"$nunit2.time"/> seconds
41 <xsl:when test=
"count($testsuite.list) + count($nunit2.suite.list) = 0">
42 <tr><td colspan=
"2" class=
"section-data">No Tests Run
</td></tr>
43 <tr><td colspan=
"2" class=
"section-error">This project doesn't have any tests
</td></tr>
46 <xsl:when test=
"$totalErrorsAndFailures = 0">
47 <tr><td colspan=
"2" class=
"section-data">All Tests Passed
</td></tr>
51 <xsl:apply-templates select=
"$testcase.error.list"/>
52 <xsl:apply-templates select=
"$testcase.failure.list | $nunit2.failure.list"/>
53 <xsl:apply-templates select=
"$nunit2.notrun.list"/>
55 <tr><td colspan=
"2"> </td></tr>
57 <xsl:if test=
"$totalErrorsAndFailures > 0">
59 <td class=
"sectionheader" colspan=
"2">
60 Unit Test Failure and Error Details (
<xsl:value-of select=
"$totalErrorsAndFailures"/>)
64 <!-- (PENDING) Why doesn't this work if set up as variables up top? -->
65 <xsl:call-template name=
"testdetail">
66 <xsl:with-param name=
"detailnodes" select=
"//testsuite/testcase[.//error]"/>
69 <xsl:call-template name=
"testdetail">
70 <xsl:with-param name=
"detailnodes" select=
"//testsuite/testcase[.//failure]"/>
73 <xsl:call-template name=
"nunit2testdetail">
74 <xsl:with-param name=
"detailnodes" select=
"//test-suite/results/test-case[.//failure]"/>
77 <tr><td colspan=
"2"> </td></tr>
80 <xsl:if test=
"$nunit2.notrun > 0">
82 <td class=
"sectionheader" colspan=
"2">
83 Warning Details (
<xsl:value-of select=
"$nunit2.notrun"/>)
86 <!-- (PENDING) Why doesn't this work if set up as variables up top? -->
87 <xsl:call-template name=
"nunit2testdetail">
88 <xsl:with-param name=
"detailnodes" select=
"//test-suite/results/test-case[.//reason]"/>
90 <tr><td colspan=
"2"> </td></tr>
95 <xsl:when test=
"$junit.tests.present">
96 <xsl:variable name=
"testsuite.list" select=
"cruisecontrol//testsuite"/>
97 <xsl:variable name=
"testsuite.error.count" select=
"count($testsuite.list/error)"/>
98 <xsl:variable name=
"testcase.list" select=
"$testsuite.list/testcase"/>
99 <xsl:variable name=
"testcase.error.list" select=
"$testcase.list/error"/>
100 <xsl:variable name=
"testcase.failure.list" select=
"$testcase.list/failure"/>
101 <xsl:variable name=
"totalErrorsAndFailures" select=
"count($testcase.error.list) + count($testcase.failure.list)"/>
104 <table align=
"center" cellpadding=
"2" cellspacing=
"0" border=
"0" width=
"100%">
108 <td class=
"sectionheader" colspan=
"2">
109 Tests run:
<xsl:value-of select=
"count($testcase.list)"/>,
110  Failures:
<xsl:value-of select=
"$totalErrorsAndFailures"/>,
111  Time:
<xsl:value-of select=
"sum($testcase.list/@time)"/> seconds
116 <xsl:when test=
"count($testsuite.list) = 0">
118 <td colspan=
"2" class=
"section-data">
123 <td colspan=
"2" class=
"section-error">
124 This project doesn't have any tests
129 <xsl:when test=
"$totalErrorsAndFailures = 0">
131 <td colspan=
"2" class=
"section-data">
138 <xsl:apply-templates select=
"$testcase.error.list"/>
139 <xsl:apply-templates select=
"$testcase.failure.list"/>
141 <tr><td colspan=
"2"> </td></tr>
143 <xsl:if test=
"$totalErrorsAndFailures > 0">
146 <td class=
"sectionheader" colspan=
"2">
147  Unit Test Failure and Error Details:
 (
<xsl:value-of select=
"$totalErrorsAndFailures"/>)
151 <!-- (PENDING) Why doesn't this work if set up as variables up top? -->
152 <xsl:call-template name=
"testdetail">
153 <xsl:with-param name=
"detailnodes" select=
"//testsuite/testcase[.//error]"/>
156 <xsl:call-template name=
"testdetail">
157 <xsl:with-param name=
"detailnodes" select=
"//testsuite/testcase[.//failure]"/>
161 <tr><td colspan=
"2"> </td></tr>
170 <!-- UnitTest Errors -->
171 <xsl:template match=
"error">
173 <xsl:if test=
"position() mod 2 = 0">
174 <xsl:attribute name=
"class">section-oddrow
</xsl:attribute>
176 <td class=
"section-data">Error
</td>
177 <td class=
"section-data"><xsl:value-of select=
"../@name"/></td>
181 <!-- UnitTest Failures -->
182 <xsl:template match=
"failure">
184 <xsl:if test=
"($testsuite.error.count + position()) mod 2 = 0">
185 <xsl:attribute name=
"class">section-oddrow
</xsl:attribute>
187 <td class=
"section-data">Failure
</td>
188 <td class=
"section-data"><xsl:value-of select=
"../@name"/></td>
192 <!-- UnitTest Warnings -->
193 <xsl:template match=
"reason">
195 <xsl:if test=
"($totalErrorsAndFailures + position()) mod 2 = 0">
196 <xsl:attribute name=
"class">section-oddrow
</xsl:attribute>
198 <td class=
"section-data">Warning
</td>
199 <td class=
"section-data"><xsl:value-of select=
"../@name"/></td>
203 <!-- UnitTest Errors And Failures Detail Template -->
204 <xsl:template name=
"testdetail">
205 <xsl:param name=
"detailnodes"/>
207 <xsl:for-each select=
"$detailnodes">
209 <xsl:if test=
"position() > 1">
210 <tr><td colspan=
"2"><hr size=
"1" width=
"100%" color=
"#888888"/></td></tr>
213 <tr><td class=
"section-data">Test:
</td><td class=
"section-data"><xsl:value-of select=
"@name"/></td></tr>
215 <xsl:if test=
"error">
216 <tr><td class=
"section-data">Type:
</td><td class=
"section-data"><xsl:value-of select=
"error/@type"/></td></tr>
217 <tr><td class=
"section-data">Message:
</td><td class=
"section-data"><xsl:value-of select=
"error/@message"/></td></tr>
220 <td class=
"section-error">
221 <pre><xsl:call-template name=
"br-replace">
222 <xsl:with-param name=
"word" select=
"error"/>
223 </xsl:call-template></pre>
228 <xsl:if test=
"failure">
229 <tr><td class=
"section-data">Type:
</td><td class=
"section-data"><xsl:value-of select=
"failure/@type"/></td></tr>
230 <tr><td class=
"section-data">Message:
</td><td class=
"section-data"><xsl:value-of select=
"failure/@message"/></td></tr>
233 <td class=
"section-error">
234 <pre><xsl:call-template name=
"br-replace">
235 <xsl:with-param name=
"word" select=
"failure"/>
236 </xsl:call-template></pre>
244 <!-- UnitTest Errors And Failures Detail Template -->
245 <xsl:template name=
"nunit2testdetail">
246 <xsl:param name=
"detailnodes"/>
248 <xsl:for-each select=
"$detailnodes">
250 <xsl:if test=
"position() > 1">
251 <tr><td colspan=
"2"><hr size=
"1" width=
"100%" color=
"#888888"/></td></tr>
254 <xsl:if test=
"failure">
255 <tr><td class=
"section-data">Test:
</td><td class=
"section-data"><xsl:value-of select=
"@name"/></td></tr>
256 <tr><td class=
"section-data">Type:
</td><td class=
"section-data">Failure
</td></tr>
257 <tr><td class=
"section-data">Message:
</td><td class=
"section-data"><xsl:value-of select=
"failure//message"/></td></tr>
260 <td class=
"section-error">
261 <pre><xsl:value-of select=
"failure//stack-trace"/></pre>
266 <xsl:if test=
"reason">
267 <tr><td class=
"section-data">Test:
</td><td class=
"section-data"><xsl:value-of select=
"@name"/></td></tr>
268 <tr><td class=
"section-data">Type:
</td><td class=
"section-data">Warning
</td></tr>
269 <tr><td class=
"section-data">Message:
</td><td class=
"section-data"><xsl:value-of select=
"reason//message"/></td></tr>
275 <xsl:template name=
"br-replace">
276 <xsl:param name=
"word"/>
277 <xsl:variable name=
"cr"><xsl:text>
278 <!-- </xsl:text> on next line on purpose to get newline -->
279 </xsl:text></xsl:variable>
281 <xsl:when test=
"contains($word,$cr)">
282 <xsl:value-of select=
"substring-before($word,$cr)"/>
284 <xsl:call-template name=
"br-replace">
285 <xsl:with-param name=
"word" select=
"substring-after($word,$cr)"/>
289 <xsl:value-of select=
"$word"/>