blob: f57faaace143df52170cdaec38e3de22f9b82d83 [file] [log] [blame]
david_williams403beae2007-12-09 02:10:40 +00001<xsl:stylesheet
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 version="1.0">
4 <xsl:output
5 method="html"
6 indent="yes" />
7 <xsl:decimal-format
8 decimal-separator="."
9 grouping-separator="," />
david_williams0c366d32006-12-10 07:08:39 +000010
david_williams403beae2007-12-09 02:10:40 +000011 <xsl:template match="testsuites">
12 <HTML>
13 <HEAD>
14 <style type="text/css">
15 body { font:normal 68% verdana,arial,helvetica;
16 color:#000000; } table tr td, table tr th {
17 font-size: 68%; } table.details tr th{ font-weight:
18 bold; text-align:left; background:#a6caf0; }
19 table.details tr td{ background:#eeeee0; }
david_williams0c366d32006-12-10 07:08:39 +000020
david_williams403beae2007-12-09 02:10:40 +000021 p { line-height:1.5em; margin-top:0.5em;
22 margin-bottom:1.0em; } h1 { margin: 0px 0px 5px;
23 font: 165% verdana,arial,helvetica } h2 {
24 margin-top: 1em; margin-bottom: 0.5em; font: bold
25 125% verdana,arial,helvetica } h3 { margin-bottom:
26 0.5em; font: bold 115% verdana,arial,helvetica } h4
27 { margin-bottom: 0.5em; font: bold 100%
28 verdana,arial,helvetica } h5 { margin-bottom: 0.5em;
29 font: bold 100% verdana,arial,helvetica } h6 {
30 margin-bottom: 0.5em; font: bold 100%
31 verdana,arial,helvetica } .Error { font-weight:bold;
32 color:red; } .Failure { font-weight:bold;
33 color:purple; } .Properties { text-align:right; }
34 </style>
35 <script language="JavaScript">
36 var TestCases = new Array(); var cur;
37 <xsl:for-each select="./testsuite">
38 <xsl:apply-templates select="properties" />
39 </xsl:for-each>
40
41 </script>
42 <script language="JavaScript"><![CDATA[
david_williams0c366d32006-12-10 07:08:39 +000043 function displayProperties (name) {
44 var win = window.open('','JUnitSystemProperties','scrollbars=1,resizable=1');
45 var doc = win.document.open();
46 doc.write("<html><head><title>Properties of " + name + "</title>");
47 doc.write("<style>")
48 doc.write("body {font:normal 68% verdana,arial,helvetica; color:#000000; }");
49 doc.write("table tr td, table tr th { font-size: 68%; }");
50 doc.write("table.properties { border-collapse:collapse; border-left:solid 1 #cccccc; border-top:solid 1 #cccccc; padding:5px; }");
51 doc.write("table.properties th { text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#eeeeee; }");
52 doc.write("table.properties td { font:normal; text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#fffffff; }");
53 doc.write("h3 { margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica }");
54 doc.write("</style>");
55 doc.write("</head><body>");
56 doc.write("<h3>Properties of " + name + "</h3>");
57 doc.write("<div align=\"right\"><a href=\"javascript:window.close();\">Close</a></div>");
58 doc.write("<table class='properties'>");
59 doc.write("<tr><th>Name</th><th>Value</th></tr>");
60 for (prop in TestCases[name]) {
61 doc.write("<tr><th>" + prop + "</th><td>" + TestCases[name][prop] + "</td></tr>");
62 }
63 doc.write("</table>");
64 doc.write("</body></html>");
65 doc.close();
66 win.focus();
67 }
david_williams403beae2007-12-09 02:10:40 +000068 ]]>
69 </script>
70 </HEAD>
71 <body>
72 <a name="top"></a>
73 <xsl:call-template name="pageHeader" />
74
75 <!-- Summary part -->
76 <xsl:call-template name="summary" />
77 <hr
78 size="1"
79 width="95%"
80 align="left" />
81
82 <!-- Package List part -->
83 <xsl:call-template name="packagelist" />
84 <hr
85 size="1"
86 width="95%"
87 align="left" />
88
89 <!-- For each package create its part -->
90 <xsl:call-template name="packages" />
91 <hr
92 size="1"
93 width="95%"
94 align="left" />
95
96 <!-- For each class create the part -->
97 <xsl:call-template name="classes" />
98
99 </body>
100 </HTML>
101 </xsl:template>
102
103
104
105 <!-- ================================================================== -->
106 <!-- Write a list of all packages with an hyperlink to the anchor of -->
107 <!-- of the package name. -->
108 <!-- ================================================================== -->
109 <xsl:template name="packagelist">
110 <h2>Packages</h2>
111 Note: package statistics are not computed recursively, they only
112 sum up all of its testsuites numbers.
113 <table
114 class="details"
115 border="0"
116 cellpadding="5"
117 cellspacing="2"
118 width="95%">
119 <xsl:call-template name="testsuite.test.header" />
120 <!-- list all packages recursively -->
121 <xsl:for-each
122 select="./testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
123 <xsl:sort select="@package" />
124 <xsl:variable
125 name="testsuites-in-package"
126 select="/testsuites/testsuite[./@package = current()/@package]" />
127 <xsl:variable
128 name="testCount"
129 select="sum($testsuites-in-package/@tests)" />
130 <xsl:variable
131 name="errorCount"
132 select="sum($testsuites-in-package/@errors)" />
133 <xsl:variable
134 name="failureCount"
135 select="sum($testsuites-in-package/@failures)" />
136 <xsl:variable
137 name="timeCount"
138 select="sum($testsuites-in-package/@time)" />
139
140 <!-- write a summary for the package -->
141 <tr valign="top">
142 <!-- set a nice color depending if there is an error/failure -->
143 <xsl:attribute name="class">
david_williams0c366d32006-12-10 07:08:39 +0000144 <xsl:choose>
145 <xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
146 <xsl:when test="$errorCount &gt; 0">Error</xsl:when>
147 </xsl:choose>
148 </xsl:attribute>
david_williams403beae2007-12-09 02:10:40 +0000149 <td>
150 <a href="#{@package}">
151 <xsl:value-of select="@package" />
152 </a>
153 </td>
154 <td>
155 <xsl:value-of select="$testCount" />
156 </td>
157 <td>
158 <xsl:value-of select="$errorCount" />
159 </td>
160 <td>
161 <xsl:value-of select="$failureCount" />
162 </td>
163 <td>
164 <xsl:call-template name="display-time">
165 <xsl:with-param
166 name="value"
167 select="$timeCount" />
168 </xsl:call-template>
169 </td>
170 </tr>
171 </xsl:for-each>
172 </table>
173 </xsl:template>
174
175
176 <!-- ================================================================== -->
177 <!-- Write a package level report -->
178 <!-- It creates a table with values from the document: -->
179 <!-- Name | Tests | Errors | Failures | Time -->
180 <!-- ================================================================== -->
181 <xsl:template name="packages">
182 <!-- create an anchor to this package name -->
183 <xsl:for-each
184 select="/testsuites/testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
185 <xsl:sort select="@package" />
186 <a name="{@package}"></a>
187 <h3>
188 Package
189 <xsl:value-of select="@package" />
190 </h3>
191
192 <table
193 class="details"
194 border="0"
195 cellpadding="5"
196 cellspacing="2"
197 width="95%">
198 <xsl:call-template name="testsuite.test.header" />
199
200 <!-- match the testsuites of this package -->
201 <xsl:apply-templates
202 select="/testsuites/testsuite[./@package = current()/@package]"
203 mode="print.test" />
204 </table>
205 <a href="#top">Back to top</a>
206 <p />
207 <p />
208 </xsl:for-each>
209 </xsl:template>
210
211 <xsl:template name="classes">
212 <xsl:for-each select="testsuite">
213 <xsl:sort select="@name" />
214 <!-- create an anchor to this class name -->
215 <a name="{@name}"></a>
216 <h3>
217 TestCase
218 <xsl:value-of select="@name" />
219 </h3>
220
221 <table
222 class="details"
223 border="0"
224 cellpadding="5"
225 cellspacing="2"
226 width="95%">
227 <xsl:call-template name="testcase.test.header" />
228 <!--
229 test can even not be started at all (failure to load the class)
230 so report the error directly
231 -->
232 <xsl:if test="./error">
233 <tr class="Error">
234 <td colspan="4">
235 <xsl:apply-templates select="./error" />
236 </td>
237 </tr>
238 </xsl:if>
239 <xsl:apply-templates
240 select="./testcase"
241 mode="print.test" />
242 </table>
david_williams0c366d32006-12-10 07:08:39 +0000243 <div class="Properties">
244 <a>
david_williams403beae2007-12-09 02:10:40 +0000245 <xsl:attribute name="href">javascript:displayProperties('<xsl:value-of
246 select="@package" />.<xsl:value-of
247 select="@name" />');</xsl:attribute>
248 Properties &gt;&gt;
249 </a>
david_williams0c366d32006-12-10 07:08:39 +0000250 </div>
david_williams403beae2007-12-09 02:10:40 +0000251 <p />
252
253 <a href="#top">Back to top</a>
254 </xsl:for-each>
255 </xsl:template>
256
257 <xsl:template name="summary">
258 <h2>Summary</h2>
259 <xsl:variable
260 name="testCount"
261 select="sum(testsuite/@tests)" />
262 <xsl:variable
263 name="errorCount"
264 select="sum(testsuite/@errors)" />
265 <xsl:variable
266 name="failureCount"
267 select="sum(testsuite/@failures)" />
268 <xsl:variable
269 name="timeCount"
270 select="sum(testsuite/@time)" />
271 <xsl:variable
272 name="successRate"
273 select="($testCount - $failureCount - $errorCount) div $testCount" />
274 <table
275 class="details"
276 border="0"
277 cellpadding="5"
278 cellspacing="2"
279 width="95%">
280 <tr valign="top">
281 <th>Tests</th>
282 <th>Failures</th>
283 <th>Errors</th>
284 <th>Success rate</th>
285 <th>Time</th>
286 </tr>
287 <tr valign="top">
288 <xsl:attribute name="class">
david_williams0c366d32006-12-10 07:08:39 +0000289 <xsl:choose>
290 <xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
291 <xsl:when test="$errorCount &gt; 0">Error</xsl:when>
292 </xsl:choose>
293 </xsl:attribute>
david_williams403beae2007-12-09 02:10:40 +0000294 <td>
295 <xsl:value-of select="$testCount" />
296 </td>
297 <td>
298 <xsl:value-of select="$failureCount" />
299 </td>
300 <td>
301 <xsl:value-of select="$errorCount" />
302 </td>
303 <td>
304 <xsl:call-template name="display-percent">
305 <xsl:with-param
306 name="value"
307 select="$successRate" />
308 </xsl:call-template>
309 </td>
310 <td>
311 <xsl:call-template name="display-time">
312 <xsl:with-param
313 name="value"
314 select="$timeCount" />
315 </xsl:call-template>
316 </td>
david_williams0c366d32006-12-10 07:08:39 +0000317
david_williams403beae2007-12-09 02:10:40 +0000318 </tr>
319 </table>
320 <table
321 border="0"
322 width="95%">
323 <tr>
324 <td style="text-align: justify;">
325 Note:
326 <i>failures</i>
327 are anticipated and checked for with assertions
328 while
329 <i>errors</i>
330 are unanticipated.
331 </td>
332 </tr>
333 </table>
334 </xsl:template>
david_williams0c366d32006-12-10 07:08:39 +0000335
david_williams403beae2007-12-09 02:10:40 +0000336 <!--
337 Write properties into a JavaScript data structure.
338 This is based on the original idea by Erik Hatcher (erik@hatcher.net)
339 -->
340 <xsl:template match="properties">
341 cur = TestCases['
342 <xsl:value-of select="../@package" />
343 .
344 <xsl:value-of select="../@name" />
345 '] = new Array();
346 <xsl:for-each select="property">
347 <xsl:sort select="@name" />
348 cur['
349 <xsl:value-of select="@name" />
350 '] = '
351 <xsl:call-template name="JS-escape">
352 <xsl:with-param
353 name="string"
354 select="@value" />
355 </xsl:call-template>
356 ';
357 </xsl:for-each>
358 </xsl:template>
david_williams0c366d32006-12-10 07:08:39 +0000359
david_williams403beae2007-12-09 02:10:40 +0000360 <!-- Page HEADER -->
361 <xsl:template name="pageHeader">
362 <h1>Unit Test Results</h1>
363 <table width="100%">
364 <tr>
365 <td align="left"></td>
366 <td align="right">
367 Designed for use with
368 <a href='http://www.junit.org'>JUnit</a>
369 and
370 <a href='http://jakarta.apache.org/ant'>Ant</a>
371 .
372 </td>
373 </tr>
374 </table>
375 <hr size="1" />
376 </xsl:template>
david_williams0c366d32006-12-10 07:08:39 +0000377
david_williams403beae2007-12-09 02:10:40 +0000378 <xsl:template
379 match="testsuite"
380 mode="header">
381 <tr valign="top">
382 <th width="80%">Name</th>
383 <th>Tests</th>
384 <th>Errors</th>
385 <th>Failures</th>
386 <th nowrap="nowrap">Time(s)</th>
387 </tr>
388 </xsl:template>
389
390 <!-- class header -->
391 <xsl:template name="testsuite.test.header">
392 <tr valign="top">
393 <th width="80%">Name</th>
394 <th>Tests</th>
395 <th>Errors</th>
396 <th>Failures</th>
397 <th nowrap="nowrap">Time(s)</th>
398 </tr>
399 </xsl:template>
400
401 <!-- method header -->
402 <xsl:template name="testcase.test.header">
403 <tr valign="top">
404 <th>Name</th>
405 <th>Status</th>
406 <th width="80%">Type</th>
407 <th nowrap="nowrap">Time(s)</th>
408 </tr>
409 </xsl:template>
david_williams0c366d32006-12-10 07:08:39 +0000410
411
david_williams403beae2007-12-09 02:10:40 +0000412 <!-- class information -->
413 <xsl:template
414 match="testsuite"
415 mode="print.test">
416 <tr valign="top">
417 <!-- set a nice color depending if there is an error/failure -->
418 <xsl:attribute name="class">
david_williams0c366d32006-12-10 07:08:39 +0000419 <xsl:choose>
420 <xsl:when test="@failures[.&gt; 0]">Failure</xsl:when>
421 <xsl:when test="@errors[.&gt; 0]">Error</xsl:when>
422 </xsl:choose>
423 </xsl:attribute>
david_williams0c366d32006-12-10 07:08:39 +0000424
david_williams403beae2007-12-09 02:10:40 +0000425 <!-- print testsuite information -->
426 <td>
427 <a href="#{@name}">
428 <xsl:value-of select="@name" />
429 </a>
430 </td>
431 <td>
432 <xsl:value-of select="@tests" />
433 </td>
434 <td>
435 <xsl:value-of select="@errors" />
436 </td>
437 <td>
438 <xsl:value-of select="@failures" />
439 </td>
440 <td>
441 <xsl:call-template name="display-time">
442 <xsl:with-param
443 name="value"
444 select="@time" />
445 </xsl:call-template>
446 </td>
447 </tr>
448 </xsl:template>
449
450 <xsl:template
451 match="testcase"
452 mode="print.test">
453 <tr valign="top">
454 <xsl:attribute name="class">
david_williams0c366d32006-12-10 07:08:39 +0000455 <xsl:choose>
456 <xsl:when test="failure | error">Error</xsl:when>
457 </xsl:choose>
458 </xsl:attribute>
david_williams403beae2007-12-09 02:10:40 +0000459 <td>
460 <xsl:value-of select="@name" />
461 </td>
462 <xsl:choose>
463 <xsl:when test="failure">
464 <td>Failure</td>
465 <td>
466 <xsl:apply-templates select="failure" />
467 </td>
468 </xsl:when>
469 <xsl:when test="error">
470 <td>Error</td>
471 <td>
472 <xsl:apply-templates select="error" />
473 </td>
474 </xsl:when>
475 <xsl:otherwise>
476 <td>Success</td>
477 <td></td>
478 </xsl:otherwise>
479 </xsl:choose>
480 <td>
481 <xsl:call-template name="display-time">
482 <xsl:with-param
483 name="value"
484 select="@time" />
485 </xsl:call-template>
486 </td>
487 </tr>
488 </xsl:template>
david_williams0c366d32006-12-10 07:08:39 +0000489
490
david_williams403beae2007-12-09 02:10:40 +0000491 <xsl:template match="failure">
492 <xsl:call-template name="display-failures" />
493 </xsl:template>
david_williams0c366d32006-12-10 07:08:39 +0000494
david_williams403beae2007-12-09 02:10:40 +0000495 <xsl:template match="error">
496 <xsl:call-template name="display-failures" />
497 </xsl:template>
david_williams0c366d32006-12-10 07:08:39 +0000498
david_williams403beae2007-12-09 02:10:40 +0000499 <!-- Style for the error and failure in the tescase template -->
500 <xsl:template name="display-failures">
501 <xsl:choose>
502 <xsl:when test="not(@message)">N/A</xsl:when>
503 <xsl:otherwise>
504 <xsl:value-of select="@message" />
505 </xsl:otherwise>
506 </xsl:choose>
507 <!-- display the stacktrace -->
508 <code>
509 <p />
510 <xsl:call-template name="br-replace">
511 <xsl:with-param
512 name="word"
513 select="." />
514 </xsl:call-template>
515 </code>
516 <!-- the later is better but might be problematic for non-21" monitors... -->
517 <!--pre><xsl:value-of select="."/></pre-->
518 </xsl:template>
david_williams0c366d32006-12-10 07:08:39 +0000519
david_williams403beae2007-12-09 02:10:40 +0000520 <xsl:template name="JS-escape">
521 <xsl:param name="string" />
522 <xsl:choose>
523 <!-- something isn't right here, basically all single quotes need to be replaced with backslash-single-quote
524 <xsl:when test="contains($string,'&apos;')">
525 <xsl:value-of select="substring-before($string,'&apos;')"/>
526 \&apos;
527 <xsl:call-template name="JS-escape">
528 <xsl:with-param name="string" select="substring-after($string,'&apos;')"/>
529 </xsl:call-template>
530 </xsl:when> -->
531 <xsl:when test="contains($string,'\')">
532 <xsl:value-of select="substring-before($string,'\')" />
533 \\
534 <xsl:call-template name="JS-escape">
535 <xsl:with-param
536 name="string"
537 select="substring-after($string,'\')" />
538 </xsl:call-template>
539 </xsl:when>
540 <xsl:otherwise>
541 <xsl:value-of select="$string" />
542 </xsl:otherwise>
543 </xsl:choose>
544 </xsl:template>
david_williams0c366d32006-12-10 07:08:39 +0000545
546
david_williams403beae2007-12-09 02:10:40 +0000547 <!--
548 template that will convert a carriage return into a br tag
549 @param word the text from which to convert CR to BR tag
550 -->
551 <xsl:template name="br-replace">
552 <xsl:param name="word" />
553 <xsl:choose>
554 <xsl:when test="contains($word,'&#xA;')">
555 <xsl:value-of select="substring-before($word,'&#xA;')" />
556 <br />
557 <xsl:call-template name="br-replace">
558 <xsl:with-param
559 name="word"
560 select="substring-after($word,'&#xA;')" />
561 </xsl:call-template>
562 </xsl:when>
563 <xsl:otherwise>
564 <xsl:value-of select="$word" />
565 </xsl:otherwise>
566 </xsl:choose>
567 </xsl:template>
david_williams0c366d32006-12-10 07:08:39 +0000568
david_williams403beae2007-12-09 02:10:40 +0000569 <xsl:template name="display-time">
570 <xsl:param name="value" />
571 <xsl:value-of select="format-number($value,'0.000')" />
572 </xsl:template>
david_williams0c366d32006-12-10 07:08:39 +0000573
david_williams403beae2007-12-09 02:10:40 +0000574 <xsl:template name="display-percent">
575 <xsl:param name="value" />
576 <xsl:value-of select="format-number($value,'0.00%')" />
577 </xsl:template>
david_williams0c366d32006-12-10 07:08:39 +0000578
579</xsl:stylesheet>
580