Fix the build.
[castle.git] / Samples / MonoRail / MRCCnetDashboard / Dashboard.Web / xsl / tests.xsl
blobc2a8167f3f23547775cc888b492d77479d41c9c4
1 <?xml version="1.0"?>
2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/html4/strict.dtd">
3 <xsl:output method="html"/>
5 <xsl:template match="/">
6 <xsl:variable name="tests.root" select="cruisecontrol//test-results" />
7 <div id="report">
8 <script>
9 function toggleDiv( imgId, divId )
11 eDiv = document.getElementById( divId );
12 eImg = document.getElementById( imgId );
14 if ( eDiv.style.display == "none" )
16 eDiv.style.display = "block";
17 eImg.src = "images/arrow_minus_small.gif";
19 else
21 eDiv.style.display = "none";
22 eImg.src = "images/arrow_plus_small.gif";
25 </script>
26 <h1>NUnit Test Results</h1>
27 <div id="summary">
28 <h3>Summary</h3>
29 <table>
30 <tbody>
31 <tr>
32 <td>Assemblies tested:</td>
33 <td><xsl:value-of select="count($tests.root)"/></td>
34 </tr>
35 <tr>
36 <td>Tests executed:</td>
37 <td><xsl:value-of select="count($tests.root//test-case[@executed = 'True'])"/></td>
38 </tr>
39 <tr>
40 <td>Passes:</td>
41 <td><xsl:value-of select="count($tests.root//test-case[@executed = 'True' and @success = 'True'])"/></td>
42 </tr>
43 <tr>
44 <td>Fails:</td>
45 <td><xsl:value-of select="count($tests.root//test-case[@executed = 'True' and @success = 'False'])"/></td>
46 </tr>
47 <tr>
48 <td>Ignored:</td>
49 <td><xsl:value-of select="count($tests.root//test-case[@executed = 'False'])"/></td>
50 </tr>
51 </tbody>
52 </table>
53 </div>
54 <div id="details">
55 <h3>Assembly Test Details:</h3>
56 <xsl:apply-templates select="$tests.root" />
57 </div>
58 </div>
59 </xsl:template>
61 <xsl:template match="test-results">
62 <xsl:variable name="test.suite.id" select="generate-id()" />
63 <xsl:variable name="test.suite.name" select="./@name"/>
64 <xsl:variable name="failure.count" select="count(.//results/test-case[@success='False'])" />
65 <xsl:variable name="ignored.count" select="count(.//results/test-case[@executed='False'])" />
67 <table cellpadding="2" cellspacing="0" border="0" width="98%">
68 <tr>
69 <td class="yellow-sectionheader" colspan="3" valign="top">
70 <xsl:choose>
71 <xsl:when test="$failure.count > 0">
72 <img src="images/fxcop-critical-error.gif">
73 <xsl:attribute name="title">Failed tests: <xsl:value-of select="$failure.count" /></xsl:attribute>
74 </img>
75 </xsl:when>
76 <xsl:when test="$ignored.count > 0">
77 <img src="images/fxcop-error.gif">
78 <xsl:attribute name="title">Ignored tests: <xsl:value-of select="$ignored.count" /></xsl:attribute>
79 </img>
80 </xsl:when>
81 <xsl:otherwise>
82 <img src="images/check.jpg" width="16" height="16"/>
83 </xsl:otherwise>
84 </xsl:choose>
86 <input type="image" src="images/arrow_minus_small.gif">
87 <xsl:attribute name="id">img<xsl:value-of select="$test.suite.id"/></xsl:attribute>
88 <xsl:attribute name="onclick">javascript:toggleDiv('img<xsl:value-of select="$test.suite.id"/>', 'divDetails<xsl:value-of select="$test.suite.id"/>');</xsl:attribute>
89 </input>&#160;<xsl:value-of select="$test.suite.name"/>
90 </td>
91 </tr>
92 </table>
93 <div>
94 <xsl:attribute name="id">divDetails<xsl:value-of select="$test.suite.id"/></xsl:attribute>
95 <blockquote>
96 <table>
97 <tr>
98 <th>Test Fixture</th>
99 <th>Status</th>
100 <th>Progress</th>
101 </tr>
102 <xsl:apply-templates select=".//test-suite[@success='False'][results/test-case]">
103 <xsl:sort select="@name" order="ascending" data-type="text"/>
104 </xsl:apply-templates>
105 <xsl:apply-templates select=".//test-suite[results/test-case/@executed='False']">
106 <xsl:sort select="@name" order="ascending" data-type="text"/>
107 </xsl:apply-templates>
108 <xsl:apply-templates select=".//test-suite[@success='True'][results/test-case/@executed='True']" mode="success">
109 <xsl:sort select="@name" order="ascending" data-type="text"/>
110 </xsl:apply-templates>
111 </table>
112 </blockquote>
113 </div>
114 </xsl:template>
116 <xsl:template match="test-suite" mode="success">
117 <xsl:if test="count(results/test-case[@success='False']) + count(results/test-case[@executed='False']) = 0">
118 <xsl:apply-templates select="."/>
119 </xsl:if>
120 </xsl:template>
122 <xsl:template match="test-suite">
123 <xsl:variable name="passedtests.list" select="results/test-case[@success='True']"/>
124 <xsl:variable name="ignoredtests.list" select="results/test-case[@executed='False']"/>
125 <xsl:variable name="failedtests.list" select="results/test-case[@success='False']"/>
126 <xsl:variable name="tests.count" select="count(results/test-case)"/>
127 <xsl:variable name="passedtests.count" select="count($passedtests.list)"/>
128 <xsl:variable name="ignoredtests.count" select="count($ignoredtests.list)"/>
129 <xsl:variable name="failedtests.count" select="count($failedtests.list)"/>
131 <xsl:variable name="testName" select="@name"/>
132 <tr>
133 <td valign="top" width="30%">
134 <input type="image" src="images/arrow_plus_small.gif">
135 <xsl:attribute name="id">imgTestCase_<xsl:value-of select="@name"/></xsl:attribute>
136 <xsl:attribute name="onClick">javascript:toggleDiv('imgTestCase_<xsl:value-of select="$testName"/>', 'divTest_<xsl:value-of select="$testName"/>');</xsl:attribute>
137 </input>
139 <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
140 <xsl:value-of select="@name"/>
141 </a>
142 </td>
143 <td width="70%">
144 <table border="0" cellspacing="1" width="100%">
145 <tr>
146 <xsl:if test="$passedtests.count > 0">
147 <xsl:variable name="passedtests.countpercent" select="($passedtests.count * 100) div $tests.count"/>
148 <td bgcolor="green">
149 <xsl:attribute name="width"><xsl:value-of select="$passedtests.countpercent"/>%</xsl:attribute>
150 &#160;
151 </td>
152 </xsl:if>
153 <xsl:if test="$ignoredtests.count > 0">
154 <xsl:variable name="ignoredtests.countpercent" select="($ignoredtests.count * 100) div $tests.count"/>
155 <td bgcolor="yellow">
156 <xsl:attribute name="width"><xsl:value-of select="$ignoredtests.countpercent"/>%</xsl:attribute>
157 &#160;
158 </td>
159 </xsl:if>
160 <xsl:if test="$failedtests.count > 0">
161 <xsl:variable name="failedtests.countpercent" select="($failedtests.count * 100) div $tests.count"/>
162 <td bgcolor="red">
163 <xsl:attribute name="width"><xsl:value-of select="$failedtests.countpercent"/>%</xsl:attribute>
164 &#160;
165 </td>
166 </xsl:if>
167 </tr>
168 </table>
169 <!--xsl:if test="$failedtests.count > 0 or $ignoredtests.count > 0"-->
170 <div style="display:none">
171 <xsl:attribute name="id">divTest_<xsl:value-of select="$testName"/></xsl:attribute>
172 <table border="0" cell-padding="6" cell-spacing="0" width="100%">
173 <xsl:apply-templates select="$failedtests.list"/>
174 <xsl:apply-templates select="$ignoredtests.list"/>
175 <xsl:apply-templates select="$passedtests.list"/>
176 </table>
177 </div>
178 <!--/xsl:if-->
179 </td>
180 <td valign="top">
181 (<xsl:value-of select="$passedtests.count"/>/<xsl:value-of select="$tests.count"/>)
182 </td>
183 </tr>
184 </xsl:template>
186 <xsl:template match="test-case[@success='True']">
187 <tr>
188 <xsl:if test="position() mod 2 = 0">
189 <xsl:attribute name="class">section-oddrow</xsl:attribute>
190 </xsl:if>
191 <td>
192 <img src="images\check.jpg" width="16" height="16"/>
193 </td>
194 <td>
195 <xsl:call-template name="getTestName">
196 <xsl:with-param name="name" select="@name"/>
197 </xsl:call-template>
198 </td>
199 <td>
200 <xsl:value-of select="substring-after(failure/message, '-')"/>
201 </td>
202 </tr>
203 </xsl:template>
204 <xsl:template match="test-case[@success='False']">
205 <tr>
206 <xsl:if test="position() mod 2 = 0">
207 <xsl:attribute name="class">section-oddrow</xsl:attribute>
208 </xsl:if>
209 <td>
210 <img src="images\fxcop-critical-error.gif"/>
211 </td>
212 <td>
213 <xsl:call-template name="getTestName">
214 <xsl:with-param name="name" select="@name"/>
215 </xsl:call-template>
216 </td>
217 <td bgcolor="gainsboro">
218 <xsl:value-of select="substring-after(failure/message, '-')"/><br/>
219 <xsl:value-of select="failure/message"/>
220 </td>
221 </tr>
222 </xsl:template>
224 <xsl:template match="test-case[@executed='False']">
225 <tr>
226 <xsl:if test="position() mod 2 = 0">
227 <xsl:attribute name="class">section-oddrow</xsl:attribute>
228 </xsl:if>
229 <td>
230 <img src="images\fxcop-error.gif"/>
231 </td>
232 <td>
233 <xsl:call-template name="getTestName">
234 <xsl:with-param name="name" select="@name"/>
235 </xsl:call-template>
236 </td>
237 <td>
238 <xsl:value-of select="substring-after(reason/message, '-')"/>
239 </td>
240 </tr>
241 </xsl:template>
243 <xsl:template name="getTestName">
244 <xsl:param name="name"/>
245 <xsl:choose>
246 <xsl:when test="contains($name, '.')">
247 <xsl:call-template name="getTestName">
248 <xsl:with-param name="name" select="substring-after($name, '.')"/>
249 </xsl:call-template>
250 </xsl:when>
251 <xsl:otherwise>
252 <xsl:value-of select="$name"/>
253 </xsl:otherwise>
254 </xsl:choose>
255 </xsl:template>
256 </xsl:stylesheet>