Fix the build.
[castle.git] / Samples / MonoRail / MRCCnetDashboard / Dashboard.Web / xsl / unittests.xsl
blobc00dcfa2c066c79c7f51e022f34b101d3459f44b
1 <?xml version="1.0"?>
2 <xsl:stylesheet
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="/">
29 <xsl:choose>
30 <xsl:when test="$nunit.tests.present">
31 <table class="section-table" cellpadding="2" cellspacing="0" border="0" width="98%">
33 <!-- Unit Tests -->
34 <tr>
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
37 </td>
38 </tr>
40 <xsl:choose>
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>
44 </xsl:when>
46 <xsl:when test="$totalErrorsAndFailures = 0">
47 <tr><td colspan="2" class="section-data">All Tests Passed</td></tr>
48 </xsl:when>
49 </xsl:choose>
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">
58 <tr>
59 <td class="sectionheader" colspan="2">
60 Unit Test Failure and Error Details (<xsl:value-of select="$totalErrorsAndFailures"/>)
61 </td>
62 </tr>
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]"/>
67 </xsl:call-template>
69 <xsl:call-template name="testdetail">
70 <xsl:with-param name="detailnodes" select="//testsuite/testcase[.//failure]"/>
71 </xsl:call-template>
73 <xsl:call-template name="nunit2testdetail">
74 <xsl:with-param name="detailnodes" select="//test-suite/results/test-case[.//failure]"/>
75 </xsl:call-template>
77 <tr><td colspan="2"> </td></tr>
78 </xsl:if>
80 <xsl:if test="$nunit2.notrun > 0">
81 <tr>
82 <td class="sectionheader" colspan="2">
83 Warning Details (<xsl:value-of select="$nunit2.notrun"/>)
84 </td>
85 </tr>
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]"/>
89 </xsl:call-template>
90 <tr><td colspan="2"> </td></tr>
91 </xsl:if>
92 </table>
93 </xsl:when>
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%">
106 <!-- Unit Tests -->
107 <tr>
108 <td class="sectionheader" colspan="2">
109 Tests run: <xsl:value-of select="count($testcase.list)"/>,
110 &#160;Failures: <xsl:value-of select="$totalErrorsAndFailures"/>,
111 &#160;Time: <xsl:value-of select="sum($testcase.list/@time)"/> seconds
112 </td>
113 </tr>
115 <xsl:choose>
116 <xsl:when test="count($testsuite.list) = 0">
117 <tr>
118 <td colspan="2" class="section-data">
119 No Tests Run
120 </td>
121 </tr>
122 <tr>
123 <td colspan="2" class="section-error">
124 This project doesn't have any tests
125 </td>
126 </tr>
127 </xsl:when>
129 <xsl:when test="$totalErrorsAndFailures = 0">
130 <tr>
131 <td colspan="2" class="section-data">
132 All Tests Passed
133 </td>
134 </tr>
135 </xsl:when>
136 </xsl:choose>
138 <xsl:apply-templates select="$testcase.error.list"/>
139 <xsl:apply-templates select="$testcase.failure.list"/>
140 <tr/>
141 <tr><td colspan="2">&#160;</td></tr>
143 <xsl:if test="$totalErrorsAndFailures > 0">
145 <tr>
146 <td class="sectionheader" colspan="2">
147 &#160;Unit Test Failure and Error Details:&#160;(<xsl:value-of select="$totalErrorsAndFailures"/>)
148 </td>
149 </tr>
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]"/>
154 </xsl:call-template>
156 <xsl:call-template name="testdetail">
157 <xsl:with-param name="detailnodes" select="//testsuite/testcase[.//failure]"/>
158 </xsl:call-template>
161 <tr><td colspan="2">&#160;</td></tr>
162 </xsl:if>
163 </table>
165 </xsl:when>
167 </xsl:choose>
168 </xsl:template>
170 <!-- UnitTest Errors -->
171 <xsl:template match="error">
172 <tr>
173 <xsl:if test="position() mod 2 = 0">
174 <xsl:attribute name="class">section-oddrow</xsl:attribute>
175 </xsl:if>
176 <td class="section-data">Error</td>
177 <td class="section-data"><xsl:value-of select="../@name"/></td>
178 </tr>
179 </xsl:template>
181 <!-- UnitTest Failures -->
182 <xsl:template match="failure">
183 <tr>
184 <xsl:if test="($testsuite.error.count + position()) mod 2 = 0">
185 <xsl:attribute name="class">section-oddrow</xsl:attribute>
186 </xsl:if>
187 <td class="section-data">Failure</td>
188 <td class="section-data"><xsl:value-of select="../@name"/></td>
189 </tr>
190 </xsl:template>
192 <!-- UnitTest Warnings -->
193 <xsl:template match="reason">
194 <tr>
195 <xsl:if test="($totalErrorsAndFailures + position()) mod 2 = 0">
196 <xsl:attribute name="class">section-oddrow</xsl:attribute>
197 </xsl:if>
198 <td class="section-data">Warning</td>
199 <td class="section-data"><xsl:value-of select="../@name"/></td>
200 </tr>
201 </xsl:template>
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>
211 </xsl:if>
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>
218 <tr>
219 <td></td>
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>
224 </td>
225 </tr>
226 </xsl:if>
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>
231 <tr>
232 <td></td>
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>
237 </td>
238 </tr>
239 </xsl:if>
241 </xsl:for-each>
242 </xsl:template>
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>
252 </xsl:if>
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>
258 <tr>
259 <td></td>
260 <td class="section-error">
261 <pre><xsl:value-of select="failure//stack-trace"/></pre>
262 </td>
263 </tr>
264 </xsl:if>
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>
270 </xsl:if>
272 </xsl:for-each>
273 </xsl:template>
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>
280 <xsl:choose>
281 <xsl:when test="contains($word,$cr)">
282 <xsl:value-of select="substring-before($word,$cr)"/>
283 <br/>
284 <xsl:call-template name="br-replace">
285 <xsl:with-param name="word" select="substring-after($word,$cr)"/>
286 </xsl:call-template>
287 </xsl:when>
288 <xsl:otherwise>
289 <xsl:value-of select="$word"/>
290 </xsl:otherwise>
291 </xsl:choose>
292 </xsl:template>
294 </xsl:stylesheet>