Debian Codegraph @

xmls/junit-noframes.xsl

raw
1 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:stringutils="xalan://org.apache.tools.ant.util.StringUtils" version="1.0">
2 <xsl:output method="html" indent="yes" encoding="US-ASCII"
3 doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" />
4 <xsl:decimal-format decimal-separator="." grouping-separator="," />
5 <!--
6 Copyright 2001-2004 The Apache Software Foundation.
7
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
11
12 http://www.apache.org/licenses/LICENSE-2.0
13
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
19 -->
20
21 <!--
22
23 Sample stylesheet to be used with An JUnitReport output.
24
25 It creates a non-framed report that can be useful to send via
26 e-mail or such.
27
28 @author Stephane Bailliez <a href="mailto:[email protected]"/>
29 @author Erik Hatcher <a href="mailto:[email protected]"/>
30
31 -->
32 <xsl:template match="testsuites">
33 <html>
34 <head>
35 <title>Unit Test Results</title>
36 <style type="text/css">
37 body {
38 font:normal 68% verdana,arial,helvetica;
39 color:#000000;
40 }
41 table tr td, table tr th {
42 font-size: 68%;
43 }
44 table.details tr th{
45 font-weight: bold;
46 text-align:left;
47 background:#a6caf0;
48 }
49 table.details tr td{
50 background:#eeeee0;
51 }
52
53 p {
54 line-height:1.5em;
55 margin-top:0.5em; margin-bottom:1.0em;
56 }
57 h1 {
58 margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
59 }
60 h2 {
61 margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
62 }
63 h3 {
64 margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
65 }
66 h4 {
67 margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
68 }
69 h5 {
70 margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
71 }
72 h6 {
73 margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
74 }
75 .Error {
76 font-weight:bold; color:red;
77 }
78 .Failure {
79 font-weight:bold; color:purple;
80 }
81 .Properties {
82 text-align:right;
83 }
84 </style>
85 <script type="text/javascript" language="JavaScript">
86 var TestCases = new Array();
87 var cur;
88 <xsl:for-each select="./testsuite">
89 <xsl:apply-templates select="properties"/>
90 </xsl:for-each>
91
92 </script>
93 <script type="text/javascript" language="JavaScript"><![CDATA[
94 function displayProperties (name) {
95 var win = window.open('','JUnitSystemProperties','scrollbars=1,resizable=1');
96 var doc = win.document.open();
97 doc.write("<html><head><title>Properties of " + name + "</title>");
98 doc.write("<style>")
99 doc.write("body {font:normal 68% verdana,arial,helvetica; color:#000000; }");
100 doc.write("table tr td, table tr th { font-size: 68%; }");
101 doc.write("table.properties { border-collapse:collapse; border-left:solid 1 #cccccc; border-top:solid 1 #cccccc; padding:5px; }");
102 doc.write("table.properties th { text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#eeeeee; }");
103 doc.write("table.properties td { font:normal; text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#fffffff; }");
104 doc.write("h3 { margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica }");
105 doc.write("</style>");
106 doc.write("</head><body>");
107 doc.write("<h3>Properties of " + name + "</h3>");
108 doc.write("<div align=\"right\"><a href=\"javascript:window.close();\">Close</a></div>");
109 doc.write("<table class='properties'>");
110 doc.write("<tr><th>Name</th><th>Value</th></tr>");
111 for (prop in TestCases[name]) {
112 doc.write("<tr><th>" + prop + "</th><td>" + TestCases[name][prop] + "</td></tr>");
113 }
114 doc.write("</table>");
115 doc.write("</body></html>");
116 doc.close();
117 win.focus();
118 }
119 ]]>
120 </script>
121 </head>
122 <body>
123 <a name="top"></a>
124 <xsl:call-template name="pageHeader"/>
125
126 <!-- Summary part -->
127 <xsl:call-template name="summary"/>
128 <hr size="1" width="95%" align="left"/>
129
130 <!-- Package List part -->
131 <xsl:call-template name="packagelist"/>
132 <hr size="1" width="95%" align="left"/>
133
134 <!-- For each package create its part -->
135 <xsl:call-template name="packages"/>
136 <hr size="1" width="95%" align="left"/>
137
138 <!-- For each class create the part -->
139 <xsl:call-template name="classes"/>
140
141 </body>
142 </html>
143 </xsl:template>
144
145
146
147 <!-- ================================================================== -->
148 <!-- Write a list of all packages with an hyperlink to the anchor of -->
149 <!-- of the package name. -->
150 <!-- ================================================================== -->
151 <xsl:template name="packagelist">
152 <h2>Packages</h2>
153 Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.
154 <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
155 <xsl:call-template name="testsuite.test.header"/>
156 <!-- list all packages recursively -->
157 <xsl:for-each select="./testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
158 <xsl:sort select="@package"/>
159 <xsl:variable name="testsuites-in-package" select="/testsuites/testsuite[./@package = current()/@package]"/>
160 <xsl:variable name="testCount" select="sum($testsuites-in-package/@tests)"/>
161 <xsl:variable name="errorCount" select="sum($testsuites-in-package/@errors)"/>
162 <xsl:variable name="failureCount" select="sum($testsuites-in-package/@failures)"/>
163 <xsl:variable name="timeCount" select="sum($testsuites-in-package/@time)"/>
164
165 <!-- write a summary for the package -->
166 <tr valign="top">
167 <!-- set a nice color depending if there is an error/failure -->
168 <xsl:attribute name="class">
169 <xsl:choose>
170 <xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
171 <xsl:when test="$errorCount &gt; 0">Error</xsl:when>
172 </xsl:choose>
173 </xsl:attribute>
174 <td><a href="#{@package}"><xsl:value-of select="@package"/></a></td>
175 <td><xsl:value-of select="$testCount"/></td>
176 <td><xsl:value-of select="$errorCount"/></td>
177 <td><xsl:value-of select="$failureCount"/></td>
178 <td>
179 <xsl:call-template name="display-time">
180 <xsl:with-param name="value" select="$timeCount"/>
181 </xsl:call-template>
182 </td>
183 </tr>
184 </xsl:for-each>
185 </table>
186 </xsl:template>
187
188
189 <!-- ================================================================== -->
190 <!-- Write a package level report -->
191 <!-- It creates a table with values from the document: -->
192 <!-- Name | Tests | Errors | Failures | Time -->
193 <!-- ================================================================== -->
194 <xsl:template name="packages">
195 <!-- create an anchor to this package name -->
196 <xsl:for-each select="/testsuites/testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
197 <xsl:sort select="@package"/>
198 <a name="{@package}"></a>
199 <h3>Package <xsl:value-of select="@package"/></h3>
200
201 <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
202 <xsl:call-template name="testsuite.test.header"/>
203
204 <!-- match the testsuites of this package -->
205 <xsl:apply-templates select="/testsuites/testsuite[./@package = current()/@package]" mode="print.test"/>
206 </table>
207 <a href="#top">Back to top</a>
208 <p/>
209 <p/>
210 </xsl:for-each>
211 </xsl:template>
212
213 <xsl:template name="classes">
214 <xsl:for-each select="testsuite">
215 <xsl:sort select="@name"/>
216 <!-- create an anchor to this class name -->
217 <a name="{@name}"></a>
218 <h3>TestCase <xsl:value-of select="@name"/></h3>
219
220 <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
221 <xsl:call-template name="testcase.test.header"/>
222 <!--
223 test can even not be started at all (failure to load the class)
224 so report the error directly
225 -->
226 <xsl:if test="./error">
227 <tr class="Error">
228 <td colspan="4"><xsl:apply-templates select="./error"/></td>
229 </tr>
230 </xsl:if>
231 <xsl:apply-templates select="./testcase" mode="print.test"/>
232 </table>
233 <div class="Properties">
234 <a>
235 <xsl:attribute name="href">javascript:displayProperties('<xsl:value-of select="@package"/>.<xsl:value-of select="@name"/>');</xsl:attribute>
236 Properties &#187;
237 </a>
238 </div>
239 <p/>
240
241 <a href="#top">Back to top</a>
242 </xsl:for-each>
243 </xsl:template>
244
245 <xsl:template name="summary">
246 <h2>Summary</h2>
247 <xsl:variable name="testCount" select="sum(testsuite/@tests)"/>
248 <xsl:variable name="errorCount" select="sum(testsuite/@errors)"/>
249 <xsl:variable name="failureCount" select="sum(testsuite/@failures)"/>
250 <xsl:variable name="timeCount" select="sum(testsuite/@time)"/>
251 <xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/>
252 <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
253 <tr valign="top">
254 <th>Tests</th>
255 <th>Failures</th>
256 <th>Errors</th>
257 <th>Success rate</th>
258 <th>Time</th>
259 </tr>
260 <tr valign="top">
261 <xsl:attribute name="class">
262 <xsl:choose>
263 <xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
264 <xsl:when test="$errorCount &gt; 0">Error</xsl:when>
265 </xsl:choose>
266 </xsl:attribute>
267 <td><xsl:value-of select="$testCount"/></td>
268 <td><xsl:value-of select="$failureCount"/></td>
269 <td><xsl:value-of select="$errorCount"/></td>
270 <td>
271 <xsl:call-template name="display-percent">
272 <xsl:with-param name="value" select="$successRate"/>
273 </xsl:call-template>
274 </td>
275 <td>
276 <xsl:call-template name="display-time">
277 <xsl:with-param name="value" select="$timeCount"/>
278 </xsl:call-template>
279 </td>
280
281 </tr>
282 </table>
283 <table border="0" width="95%">
284 <tr>
285 <td style="text-align: justify;">
286 Note: <i>failures</i> are anticipated and checked for with assertions while <i>errors</i> are unanticipated.
287 </td>
288 </tr>
289 </table>
290 </xsl:template>
291
292 <!--
293 Write properties into a JavaScript data structure.
294 This is based on the original idea by Erik Hatcher ([email protected])
295 -->
296 <xsl:template match="properties">
297 cur = TestCases['<xsl:value-of select="../@package"/>.<xsl:value-of select="../@name"/>'] = new Array();
298 <xsl:for-each select="property">
299 <xsl:sort select="@name"/>
300 cur['<xsl:value-of select="@name"/>'] = '<xsl:call-template name="JS-escape"><xsl:with-param name="string" select="@value"/></xsl:call-template>';
301 </xsl:for-each>
302 </xsl:template>
303
304 <!-- Page HEADER -->
305 <xsl:template name="pageHeader">
306 <h1>Unit Test Results</h1>
307 <table width="100%">
308 <tr>
309 <td align="left"></td>
310 <td align="right">Designed for use with <a href='http://www.junit.org'>JUnit</a> and <a href='http://jakarta.apache.org/ant'>Ant</a>.</td>
311 </tr>
312 </table>
313 <hr size="1"/>
314 </xsl:template>
315
316 <xsl:template match="testsuite" mode="header">
317 <tr valign="top">
318 <th width="80%">Name</th>
319 <th>Tests</th>
320 <th>Errors</th>
321 <th>Failures</th>
322 <th nowrap="nowrap">Time(s)</th>
323 </tr>
324 </xsl:template>
325
326 <!-- class header -->
327 <xsl:template name="testsuite.test.header">
328 <tr valign="top">
329 <th width="80%">Name</th>
330 <th>Tests</th>
331 <th>Errors</th>
332 <th>Failures</th>
333 <th nowrap="nowrap">Time(s)</th>
334 </tr>
335 </xsl:template>
336
337 <!-- method header -->
338 <xsl:template name="testcase.test.header">
339 <tr valign="top">
340 <th>Name</th>
341 <th>Status</th>
342 <th width="80%">Type</th>
343 <th nowrap="nowrap">Time(s)</th>
344 </tr>
345 </xsl:template>
346
347
348 <!-- class information -->
349 <xsl:template match="testsuite" mode="print.test">
350 <tr valign="top">
351 <!-- set a nice color depending if there is an error/failure -->
352 <xsl:attribute name="class">
353 <xsl:choose>
354 <xsl:when test="@failures[.&gt; 0]">Failure</xsl:when>
355 <xsl:when test="@errors[.&gt; 0]">Error</xsl:when>
356 </xsl:choose>
357 </xsl:attribute>
358
359 <!-- print testsuite information -->
360 <td><a href="#{@name}"><xsl:value-of select="@name"/></a></td>
361 <td><xsl:value-of select="@tests"/></td>
362 <td><xsl:value-of select="@errors"/></td>
363 <td><xsl:value-of select="@failures"/></td>
364 <td>
365 <xsl:call-template name="display-time">
366 <xsl:with-param name="value" select="@time"/>
367 </xsl:call-template>
368 </td>
369 </tr>
370 </xsl:template>
371
372 <xsl:template match="testcase" mode="print.test">
373 <tr valign="top">
374 <xsl:attribute name="class">
375 <xsl:choose>
376 <xsl:when test="failure | error">Error</xsl:when>
377 </xsl:choose>
378 </xsl:attribute>
379 <td><xsl:value-of select="@name"/></td>
380 <xsl:choose>
381 <xsl:when test="failure">
382 <td>Failure</td>
383 <td><xsl:apply-templates select="failure"/></td>
384 </xsl:when>
385 <xsl:when test="error">
386 <td>Error</td>
387 <td><xsl:apply-templates select="error"/></td>
388 </xsl:when>
389 <xsl:otherwise>
390 <td>Success</td>
391 <td></td>
392 </xsl:otherwise>
393 </xsl:choose>
394 <td>
395 <xsl:call-template name="display-time">
396 <xsl:with-param name="value" select="@time"/>
397 </xsl:call-template>
398 </td>
399 </tr>
400 </xsl:template>
401
402
403 <xsl:template match="failure">
404 <xsl:call-template name="display-failures"/>
405 </xsl:template>
406
407 <xsl:template match="error">
408 <xsl:call-template name="display-failures"/>
409 </xsl:template>
410
411 <!-- Style for the error and failure in the tescase template -->
412 <xsl:template name="display-failures">
413 <xsl:choose>
414 <xsl:when test="not(@message)">N/A</xsl:when>
415 <xsl:otherwise>
416 <xsl:value-of select="@message"/>
417 </xsl:otherwise>
418 </xsl:choose>
419 <!-- display the stacktrace -->
420 <code>
421 <br/><br/>
422 <xsl:call-template name="br-replace">
423 <xsl:with-param name="word" select="."/>
424 </xsl:call-template>
425 </code>
426 <!-- the later is better but might be problematic for non-21" monitors... -->
427 <!--pre><xsl:value-of select="."/></pre-->
428 </xsl:template>
429
430 <xsl:template name="JS-escape">
431 <xsl:param name="string"/>
432 <xsl:param name="tmp1" select="stringutils:replace(string($string),'\','\\')"/>
433 <xsl:param name="tmp2" select="stringutils:replace(string($tmp1),&quot;'&quot;,&quot;\&apos;&quot;)"/>
434 <xsl:value-of select="$tmp2"/>
435 </xsl:template>
436
437 <!--
438 template that will convert a carriage return into a br tag
439 @param word the text from which to convert CR to BR tag
440 -->
441 <xsl:template name="br-replace">
442 <xsl:param name="word"/>
443 <xsl:choose>
444 <xsl:when test="contains($word,'&#xA;')">
445 <xsl:value-of select="substring-before($word,'&#xA;')"/>
446 <br/>
447 <xsl:call-template name="br-replace">
448 <xsl:with-param name="word" select="substring-after($word,'&#xA;')"/>
449 </xsl:call-template>
450 </xsl:when>
451 <xsl:otherwise>
452 <xsl:value-of select="$word"/>
453 </xsl:otherwise>
454 </xsl:choose>
455 </xsl:template>
456
457 <xsl:template name="display-time">
458 <xsl:param name="value"/>
459 <xsl:value-of select="format-number($value,'0.000')"/>
460 </xsl:template>
461
462 <xsl:template name="display-percent">
463 <xsl:param name="value"/>
464 <xsl:value-of select="format-number($value,'0.00%')"/>
465 </xsl:template>
466
467 </xsl:stylesheet>
468