source: release-kits/lirk3/resources/gs3-release-maker/ant/etc/junit-noframes.xsl@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

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