1 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" |
---|
2 | xmlns:exsl="http://exslt.org/common" |
---|
3 | xmlns:str="http://exslt.org/strings" |
---|
4 | xmlns:date="http://exslt.org/dates-and-times" |
---|
5 | extension-element-prefixes="exsl str date"> |
---|
6 | <xsl:include href="str.replace.function.xsl"/> |
---|
7 | <xsl:output method="html" indent="yes" encoding="US-ASCII"/> |
---|
8 | <xsl:decimal-format decimal-separator="." grouping-separator=","/> |
---|
9 | <!-- |
---|
10 | Copyright 2001-2004 The Apache Software Foundation |
---|
11 | |
---|
12 | Licensed under the Apache License, Version 2.0 (the "License"); |
---|
13 | you may not use this file except in compliance with the License. |
---|
14 | You may obtain a copy of the License at |
---|
15 | |
---|
16 | http://www.apache.org/licenses/LICENSE-2.0 |
---|
17 | |
---|
18 | Unless required by applicable law or agreed to in writing, software |
---|
19 | distributed under the License is distributed on an "AS IS" BASIS, |
---|
20 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
21 | See the License for the specific language governing permissions and |
---|
22 | limitations under the License. |
---|
23 | --> |
---|
24 | |
---|
25 | <!-- |
---|
26 | |
---|
27 | Sample stylesheet to be used with Phing/PHPUnit2 output. |
---|
28 | Based on JUnit stylesheets from Apache Ant. |
---|
29 | |
---|
30 | It creates a set of HTML files a la javadoc where you can browse easily |
---|
31 | through all packages and classes. |
---|
32 | |
---|
33 | @author Michiel Rook <a href="mailto:michiel.rook@gmail.com"/> |
---|
34 | @author Stephane Bailliez <a href="mailto:sbailliez@apache.org"/> |
---|
35 | @author Erik Hatcher <a href="mailto:ehatcher@apache.org"/> |
---|
36 | @author Martijn Kruithof <a href="mailto:martijn@kruithof.xs4all.nl"/> |
---|
37 | |
---|
38 | --> |
---|
39 | <xsl:param name="output.dir" select="'.'"/> |
---|
40 | |
---|
41 | |
---|
42 | <xsl:template match="testsuites"> |
---|
43 | <!-- create the index.html --> |
---|
44 | <exsl:document href="efile://{$output.dir}/index.html"> |
---|
45 | <xsl:call-template name="index.html"/> |
---|
46 | </exsl:document> |
---|
47 | |
---|
48 | <!-- create the stylesheet.css --> |
---|
49 | <exsl:document href="efile://{$output.dir}/stylesheet.css"> |
---|
50 | <xsl:call-template name="stylesheet.css"/> |
---|
51 | </exsl:document> |
---|
52 | |
---|
53 | <!-- create the overview-packages.html at the root --> |
---|
54 | <exsl:document href="efile://{$output.dir}/overview-summary.html"> |
---|
55 | <xsl:apply-templates select="." mode="overview.packages"/> |
---|
56 | </exsl:document> |
---|
57 | |
---|
58 | <!-- create the all-packages.html at the root --> |
---|
59 | <exsl:document href="efile://{$output.dir}/overview-frame.html"> |
---|
60 | <xsl:apply-templates select="." mode="all.packages"/> |
---|
61 | </exsl:document> |
---|
62 | |
---|
63 | <!-- create the all-classes.html at the root --> |
---|
64 | <exsl:document href="efile://{$output.dir}/allclasses-frame.html"> |
---|
65 | <xsl:apply-templates select="." mode="all.classes"/> |
---|
66 | </exsl:document> |
---|
67 | |
---|
68 | <!-- process all packages --> |
---|
69 | <xsl:for-each select="./testsuite[not(./@package = preceding-sibling::testsuite/@package)]"> |
---|
70 | <xsl:call-template name="package"> |
---|
71 | <xsl:with-param name="name" select="@package"/> |
---|
72 | </xsl:call-template> |
---|
73 | </xsl:for-each> |
---|
74 | </xsl:template> |
---|
75 | |
---|
76 | |
---|
77 | <xsl:template name="package"> |
---|
78 | <xsl:param name="name"/> |
---|
79 | <xsl:variable name="package.dir"> |
---|
80 | <xsl:if test="not($name = '')"><xsl:value-of select="translate($name,'.','/')"/></xsl:if> |
---|
81 | <xsl:if test="$name = ''">.</xsl:if> |
---|
82 | </xsl:variable> |
---|
83 | <!--Processing package <xsl:value-of select="@name"/> in <xsl:value-of select="$output.dir"/> --> |
---|
84 | <!-- create a classes-list.html in the package directory --> |
---|
85 | <exsl:document href="efile://{$output.dir}/{$package.dir}/package-frame.html"> |
---|
86 | <xsl:call-template name="classes.list"> |
---|
87 | <xsl:with-param name="name" select="$name"/> |
---|
88 | </xsl:call-template> |
---|
89 | </exsl:document> |
---|
90 | |
---|
91 | <!-- create a package-summary.html in the package directory --> |
---|
92 | <exsl:document href="efile://{$output.dir}/{$package.dir}/package-summary.html"> |
---|
93 | <xsl:call-template name="package.summary"> |
---|
94 | <xsl:with-param name="name" select="$name"/> |
---|
95 | </xsl:call-template> |
---|
96 | </exsl:document> |
---|
97 | |
---|
98 | <!-- for each class, creates a @name.html --> |
---|
99 | <!-- @bug there will be a problem with inner classes having the same name, it will be overwritten --> |
---|
100 | <xsl:for-each select="/testsuites/testsuite[@package = $name]"> |
---|
101 | <exsl:document href="efile://{$output.dir}/{$package.dir}/{@name}.html"> |
---|
102 | <xsl:apply-templates select="." mode="class.details"/> |
---|
103 | </exsl:document> |
---|
104 | <xsl:if test="string-length(./system-out)!=0"> |
---|
105 | <exsl:document href="efile://{$output.dir}/{$package.dir}/{@name}-out.txt"> |
---|
106 | <xsl:value-of select="./system-out" /> |
---|
107 | </exsl:document> |
---|
108 | </xsl:if> |
---|
109 | <xsl:if test="string-length(./system-err)!=0"> |
---|
110 | <exsl:document href="efile://{$output.dir}/{$package.dir}/{@name}-err.txt"> |
---|
111 | <xsl:value-of select="./system-err" /> |
---|
112 | </exsl:document> |
---|
113 | </xsl:if> |
---|
114 | </xsl:for-each> |
---|
115 | </xsl:template> |
---|
116 | |
---|
117 | <xsl:template name="index.html"> |
---|
118 | <html> |
---|
119 | <head> |
---|
120 | <title>Unit Test Results.</title> |
---|
121 | </head> |
---|
122 | <frameset cols="20%,80%"> |
---|
123 | <frameset rows="30%,70%"> |
---|
124 | <frame src="overview-frame.html" name="packageListFrame"/> |
---|
125 | <frame src="allclasses-frame.html" name="classListFrame"/> |
---|
126 | </frameset> |
---|
127 | <frame src="overview-summary.html" name="classFrame"/> |
---|
128 | <noframes> |
---|
129 | <h2>Frame Alert</h2> |
---|
130 | <p> |
---|
131 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. |
---|
132 | </p> |
---|
133 | </noframes> |
---|
134 | </frameset> |
---|
135 | </html> |
---|
136 | </xsl:template> |
---|
137 | |
---|
138 | <!-- this is the stylesheet css to use for nearly everything --> |
---|
139 | <xsl:template name="stylesheet.css"> |
---|
140 | body { |
---|
141 | font-family: verdana,arial,helvetica; |
---|
142 | color:#000000; |
---|
143 | font-size: 12px; |
---|
144 | } |
---|
145 | table tr td, table tr th { |
---|
146 | font-family: verdana,arial,helvetica; |
---|
147 | font-size: 12px; |
---|
148 | } |
---|
149 | table.details tr th{ |
---|
150 | font-family: verdana,arial,helvetica; |
---|
151 | font-weight: bold; |
---|
152 | text-align:left; |
---|
153 | background:#a6caf0; |
---|
154 | } |
---|
155 | table.details tr td{ |
---|
156 | background:#eeeee0; |
---|
157 | } |
---|
158 | |
---|
159 | p { |
---|
160 | line-height:1.5em; |
---|
161 | margin-top:0.5em; margin-bottom:1.0em; |
---|
162 | font-size: 12px; |
---|
163 | } |
---|
164 | h1 { |
---|
165 | margin: 0px 0px 5px; |
---|
166 | font-family: verdana,arial,helvetica; |
---|
167 | } |
---|
168 | h2 { |
---|
169 | margin-top: 1em; margin-bottom: 0.5em; |
---|
170 | font-family: verdana,arial,helvetica; |
---|
171 | } |
---|
172 | h3 { |
---|
173 | margin-bottom: 0.5em; |
---|
174 | font-family: verdana,arial,helvetica; |
---|
175 | } |
---|
176 | h4 { |
---|
177 | margin-bottom: 0.5em; |
---|
178 | font-family: verdana,arial,helvetica; |
---|
179 | } |
---|
180 | h5 { |
---|
181 | margin-bottom: 0.5em; |
---|
182 | font-family: verdana,arial,helvetica; |
---|
183 | } |
---|
184 | h6 { |
---|
185 | margin-bottom: 0.5em; |
---|
186 | font-family: verdana,arial,helvetica; |
---|
187 | } |
---|
188 | .Error { |
---|
189 | font-weight:bold; color:red; |
---|
190 | } |
---|
191 | .Failure { |
---|
192 | font-weight:bold; color:purple; |
---|
193 | } |
---|
194 | .small { |
---|
195 | font-size: 9px; |
---|
196 | } |
---|
197 | a { |
---|
198 | color: #003399; |
---|
199 | } |
---|
200 | a:hover { |
---|
201 | color: #888888; |
---|
202 | } |
---|
203 | </xsl:template> |
---|
204 | |
---|
205 | |
---|
206 | <!-- ====================================================================== |
---|
207 | This page is created for every testsuite class. |
---|
208 | It prints a summary of the testsuite and detailed information about |
---|
209 | testcase methods. |
---|
210 | ====================================================================== --> |
---|
211 | <xsl:template match="testsuite" mode="class.details"> |
---|
212 | <xsl:variable name="package.name" select="@package"/> |
---|
213 | <xsl:variable name="class.name"><xsl:if test="not($package.name = '')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></xsl:variable> |
---|
214 | <html> |
---|
215 | <head> |
---|
216 | <title>Unit Test Results: <xsl:value-of select="$class.name"/></title> |
---|
217 | <xsl:call-template name="create.stylesheet.link"> |
---|
218 | <xsl:with-param name="package.name" select="$package.name"/> |
---|
219 | </xsl:call-template> |
---|
220 | </head> |
---|
221 | <body> |
---|
222 | <xsl:call-template name="pageHeader"/> |
---|
223 | <h3>Class <xsl:value-of select="$class.name"/></h3> |
---|
224 | |
---|
225 | |
---|
226 | <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%"> |
---|
227 | <xsl:call-template name="testsuite.test.header"/> |
---|
228 | <xsl:apply-templates select="." mode="print.test"/> |
---|
229 | </table> |
---|
230 | |
---|
231 | <h2>Tests</h2> |
---|
232 | <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%"> |
---|
233 | <xsl:call-template name="testcase.test.header"/> |
---|
234 | <!-- |
---|
235 | test can even not be started at all (failure to load the class) |
---|
236 | so report the error directly |
---|
237 | --> |
---|
238 | <xsl:if test="./error"> |
---|
239 | <tr class="Error"> |
---|
240 | <td colspan="4"><xsl:apply-templates select="./error"/></td> |
---|
241 | </tr> |
---|
242 | </xsl:if> |
---|
243 | <xsl:apply-templates select="./testcase | ./testsuite/testcase" mode="print.test"/> |
---|
244 | </table> |
---|
245 | <xsl:call-template name="pageFooter"/> |
---|
246 | </body> |
---|
247 | </html> |
---|
248 | </xsl:template> |
---|
249 | |
---|
250 | <!-- ====================================================================== |
---|
251 | This page is created for every package. |
---|
252 | It prints the name of all classes that belongs to this package. |
---|
253 | @param name the package name to print classes. |
---|
254 | ====================================================================== --> |
---|
255 | <!-- list of classes in a package --> |
---|
256 | <xsl:template name="classes.list"> |
---|
257 | <xsl:param name="name"/> |
---|
258 | <html> |
---|
259 | <head> |
---|
260 | <title>Unit Test Classes: <xsl:value-of select="$name"/></title> |
---|
261 | <xsl:call-template name="create.stylesheet.link"> |
---|
262 | <xsl:with-param name="package.name" select="$name"/> |
---|
263 | </xsl:call-template> |
---|
264 | </head> |
---|
265 | <body> |
---|
266 | <table width="100%"> |
---|
267 | <tr> |
---|
268 | <td nowrap="nowrap"> |
---|
269 | <h2><a href="package-summary.html" target="classFrame"> |
---|
270 | <xsl:value-of select="$name"/> |
---|
271 | <xsl:if test="$name = ''"><none></xsl:if> |
---|
272 | </a></h2> |
---|
273 | </td> |
---|
274 | </tr> |
---|
275 | </table> |
---|
276 | |
---|
277 | <h2>Classes</h2> |
---|
278 | <table width="100%"> |
---|
279 | <xsl:for-each select="/testsuites/testsuite[./@package = $name]"> |
---|
280 | <xsl:sort select="@name"/> |
---|
281 | <tr> |
---|
282 | <td nowrap="nowrap"> |
---|
283 | <a href="{@name}.html" target="classFrame"><xsl:value-of select="@name"/></a> |
---|
284 | </td> |
---|
285 | </tr> |
---|
286 | </xsl:for-each> |
---|
287 | </table> |
---|
288 | </body> |
---|
289 | </html> |
---|
290 | </xsl:template> |
---|
291 | |
---|
292 | |
---|
293 | <!-- |
---|
294 | Creates an all-classes.html file that contains a link to all package-summary.html |
---|
295 | on each class. |
---|
296 | --> |
---|
297 | <xsl:template match="testsuites" mode="all.classes"> |
---|
298 | <html> |
---|
299 | <head> |
---|
300 | <title>All Unit Test Classes</title> |
---|
301 | <xsl:call-template name="create.stylesheet.link"> |
---|
302 | <xsl:with-param name="package.name"/> |
---|
303 | </xsl:call-template> |
---|
304 | </head> |
---|
305 | <body> |
---|
306 | <h2>Classes</h2> |
---|
307 | <table width="100%"> |
---|
308 | <xsl:apply-templates select="testsuite" mode="all.classes"> |
---|
309 | <xsl:sort select="@name"/> |
---|
310 | </xsl:apply-templates> |
---|
311 | </table> |
---|
312 | </body> |
---|
313 | </html> |
---|
314 | </xsl:template> |
---|
315 | |
---|
316 | <xsl:template match="testsuite" mode="all.classes"> |
---|
317 | <xsl:variable name="package.name" select="@package"/> |
---|
318 | <tr> |
---|
319 | <td nowrap="nowrap"> |
---|
320 | <a target="classFrame"> |
---|
321 | <xsl:attribute name="href"> |
---|
322 | <xsl:if test="not($package.name='')"> |
---|
323 | <xsl:value-of select="translate($package.name,'.','/')"/><xsl:text>/</xsl:text> |
---|
324 | </xsl:if><xsl:value-of select="@name"/><xsl:text>.html</xsl:text> |
---|
325 | </xsl:attribute> |
---|
326 | <xsl:value-of select="@name"/> |
---|
327 | </a> |
---|
328 | </td> |
---|
329 | </tr> |
---|
330 | </xsl:template> |
---|
331 | |
---|
332 | |
---|
333 | <!-- |
---|
334 | Creates an html file that contains a link to all package-summary.html files on |
---|
335 | each package existing on testsuites. |
---|
336 | @bug there will be a problem here, I don't know yet how to handle unnamed package :( |
---|
337 | --> |
---|
338 | <xsl:template match="testsuites" mode="all.packages"> |
---|
339 | <html> |
---|
340 | <head> |
---|
341 | <title>All Unit Test Packages</title> |
---|
342 | <xsl:call-template name="create.stylesheet.link"> |
---|
343 | <xsl:with-param name="package.name"/> |
---|
344 | </xsl:call-template> |
---|
345 | </head> |
---|
346 | <body> |
---|
347 | <h2><a href="overview-summary.html" target="classFrame">Home</a></h2> |
---|
348 | <h2>Packages</h2> |
---|
349 | <table width="100%"> |
---|
350 | <xsl:apply-templates select="testsuite[not(./@package = preceding-sibling::testsuite/@package)]" mode="all.packages"> |
---|
351 | <xsl:sort select="@package"/> |
---|
352 | </xsl:apply-templates> |
---|
353 | </table> |
---|
354 | </body> |
---|
355 | </html> |
---|
356 | </xsl:template> |
---|
357 | |
---|
358 | <xsl:template match="testsuite" mode="all.packages"> |
---|
359 | <tr> |
---|
360 | <td nowrap="nowrap"> |
---|
361 | <a href="./{translate(@package,'.','/')}/package-summary.html" target="classFrame"> |
---|
362 | <xsl:value-of select="@package"/> |
---|
363 | <xsl:if test="@package = ''"><none></xsl:if> |
---|
364 | </a> |
---|
365 | </td> |
---|
366 | </tr> |
---|
367 | </xsl:template> |
---|
368 | |
---|
369 | |
---|
370 | <xsl:template match="testsuites" mode="overview.packages"> |
---|
371 | <html> |
---|
372 | <head> |
---|
373 | <title>Unit Test Results: Summary</title> |
---|
374 | <xsl:call-template name="create.stylesheet.link"> |
---|
375 | <xsl:with-param name="package.name"/> |
---|
376 | </xsl:call-template> |
---|
377 | </head> |
---|
378 | <body> |
---|
379 | <xsl:attribute name="onload">open('allclasses-frame.html','classListFrame')</xsl:attribute> |
---|
380 | <xsl:call-template name="pageHeader"/> |
---|
381 | <h2>Summary</h2> |
---|
382 | <xsl:variable name="testCount" select="sum(testsuite/@tests)"/> |
---|
383 | <xsl:variable name="errorCount" select="sum(testsuite/@errors)"/> |
---|
384 | <xsl:variable name="failureCount" select="sum(testsuite/@failures)"/> |
---|
385 | <xsl:variable name="timeCount" select="sum(testsuite/@time)"/> |
---|
386 | <xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/> |
---|
387 | <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%"> |
---|
388 | <tr valign="top"> |
---|
389 | <th>Tests</th> |
---|
390 | <th>Failures</th> |
---|
391 | <th>Errors</th> |
---|
392 | <th>Success rate</th> |
---|
393 | <th>Time</th> |
---|
394 | </tr> |
---|
395 | <tr valign="top"> |
---|
396 | <xsl:attribute name="class"> |
---|
397 | <xsl:choose> |
---|
398 | <xsl:when test="$errorCount > 0">Error</xsl:when> |
---|
399 | <xsl:when test="$failureCount > 0">Failure</xsl:when> |
---|
400 | <xsl:otherwise>Pass</xsl:otherwise> |
---|
401 | </xsl:choose> |
---|
402 | </xsl:attribute> |
---|
403 | <td><xsl:value-of select="$testCount"/></td> |
---|
404 | <td><xsl:value-of select="$failureCount"/></td> |
---|
405 | <td><xsl:value-of select="$errorCount"/></td> |
---|
406 | <td> |
---|
407 | <xsl:call-template name="display-percent"> |
---|
408 | <xsl:with-param name="value" select="$successRate"/> |
---|
409 | </xsl:call-template> |
---|
410 | </td> |
---|
411 | <td> |
---|
412 | <xsl:call-template name="display-time"> |
---|
413 | <xsl:with-param name="value" select="$timeCount"/> |
---|
414 | </xsl:call-template> |
---|
415 | </td> |
---|
416 | |
---|
417 | </tr> |
---|
418 | </table> |
---|
419 | <table border="0" width="95%"> |
---|
420 | <tr> |
---|
421 | <td style="text-align: justify;"> |
---|
422 | Note: <em>failures</em> are anticipated and checked for with assertions while <em>errors</em> are unanticipated. |
---|
423 | </td> |
---|
424 | </tr> |
---|
425 | </table> |
---|
426 | |
---|
427 | <h2>Packages</h2> |
---|
428 | <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%"> |
---|
429 | <xsl:call-template name="testsuite.test.header"/> |
---|
430 | <xsl:for-each select="testsuite[not(./@package = preceding-sibling::testsuite/@package)]"> |
---|
431 | <xsl:sort select="@package" order="ascending"/> |
---|
432 | <!-- get the node set containing all testsuites that have the same package --> |
---|
433 | <xsl:variable name="insamepackage" select="/testsuites/testsuite[./@package = current()/@package]"/> |
---|
434 | <tr valign="top"> |
---|
435 | <!-- display a failure if there is any failure/error in the package --> |
---|
436 | <xsl:attribute name="class"> |
---|
437 | <xsl:choose> |
---|
438 | <xsl:when test="sum($insamepackage/@errors) > 0">Error</xsl:when> |
---|
439 | <xsl:when test="sum($insamepackage/@failures) > 0">Failure</xsl:when> |
---|
440 | <xsl:otherwise>Pass</xsl:otherwise> |
---|
441 | </xsl:choose> |
---|
442 | </xsl:attribute> |
---|
443 | <td><a href="./{translate(@package,'.','/')}/package-summary.html"> |
---|
444 | <xsl:value-of select="@package"/> |
---|
445 | <xsl:if test="@package = ''"><none></xsl:if> |
---|
446 | </a></td> |
---|
447 | <td><xsl:value-of select="sum($insamepackage/@tests)"/></td> |
---|
448 | <td><xsl:value-of select="sum($insamepackage/@errors)"/></td> |
---|
449 | <td><xsl:value-of select="sum($insamepackage/@failures)"/></td> |
---|
450 | <td> |
---|
451 | <xsl:call-template name="display-time"> |
---|
452 | <xsl:with-param name="value" select="sum($insamepackage/@time)"/> |
---|
453 | </xsl:call-template> |
---|
454 | </td> |
---|
455 | </tr> |
---|
456 | </xsl:for-each> |
---|
457 | </table> |
---|
458 | <xsl:call-template name="pageFooter"/> |
---|
459 | </body> |
---|
460 | </html> |
---|
461 | </xsl:template> |
---|
462 | |
---|
463 | |
---|
464 | <xsl:template name="package.summary"> |
---|
465 | <xsl:param name="name"/> |
---|
466 | <html> |
---|
467 | <head> |
---|
468 | <xsl:call-template name="create.stylesheet.link"> |
---|
469 | <xsl:with-param name="package.name" select="$name"/> |
---|
470 | </xsl:call-template> |
---|
471 | </head> |
---|
472 | <body> |
---|
473 | <xsl:attribute name="onload">open('package-frame.html','classListFrame')</xsl:attribute> |
---|
474 | <xsl:call-template name="pageHeader"/> |
---|
475 | <h3>Package <xsl:value-of select="$name"/></h3> |
---|
476 | |
---|
477 | <!--table border="0" cellpadding="5" cellspacing="2" width="95%"> |
---|
478 | <xsl:call-template name="class.metrics.header"/> |
---|
479 | <xsl:apply-templates select="." mode="print.metrics"/> |
---|
480 | </table--> |
---|
481 | |
---|
482 | <xsl:variable name="insamepackage" select="/testsuites/testsuite[./@package = $name]"/> |
---|
483 | <xsl:if test="count($insamepackage) > 0"> |
---|
484 | <h2>Classes</h2> |
---|
485 | <p> |
---|
486 | <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%"> |
---|
487 | <xsl:call-template name="testsuite.test.header"/> |
---|
488 | <xsl:apply-templates select="$insamepackage" mode="print.test"> |
---|
489 | <xsl:sort select="@name"/> |
---|
490 | </xsl:apply-templates> |
---|
491 | </table> |
---|
492 | </p> |
---|
493 | </xsl:if> |
---|
494 | <xsl:call-template name="pageFooter"/> |
---|
495 | </body> |
---|
496 | </html> |
---|
497 | </xsl:template> |
---|
498 | |
---|
499 | |
---|
500 | <!-- |
---|
501 | transform string like a.b.c to ../../../ |
---|
502 | @param path the path to transform into a descending directory path |
---|
503 | --> |
---|
504 | <xsl:template name="path"> |
---|
505 | <xsl:param name="path"/> |
---|
506 | <xsl:if test="contains($path,'.')"> |
---|
507 | <xsl:text>../</xsl:text> |
---|
508 | <xsl:call-template name="path"> |
---|
509 | <xsl:with-param name="path"><xsl:value-of select="substring-after($path,'.')"/></xsl:with-param> |
---|
510 | </xsl:call-template> |
---|
511 | </xsl:if> |
---|
512 | <xsl:if test="not(contains($path,'.')) and not($path = '')"> |
---|
513 | <xsl:text>../</xsl:text> |
---|
514 | </xsl:if> |
---|
515 | </xsl:template> |
---|
516 | |
---|
517 | |
---|
518 | <!-- create the link to the stylesheet based on the package name --> |
---|
519 | <xsl:template name="create.stylesheet.link"> |
---|
520 | <xsl:param name="package.name"/> |
---|
521 | <link rel="stylesheet" type="text/css" title="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></link> |
---|
522 | </xsl:template> |
---|
523 | |
---|
524 | |
---|
525 | <!-- Page HEADER --> |
---|
526 | <xsl:template name="pageHeader"> |
---|
527 | <h1>Unit Test Results</h1> |
---|
528 | <table width="100%"> |
---|
529 | <tr> |
---|
530 | <td align="left"></td> |
---|
531 | <td align="right">Designed for use with <a href='http://pear.php.net/package/PHPUnit2'>PHPUnit2</a> and <a href='http://phing.info/'>Phing</a>.</td> |
---|
532 | </tr> |
---|
533 | </table> |
---|
534 | <hr size="1"/> |
---|
535 | </xsl:template> |
---|
536 | |
---|
537 | <!-- Page Footer --> |
---|
538 | <xsl:template name="pageFooter"> |
---|
539 | <table width="100%"> |
---|
540 | <tr><td><hr noshade="yes" size="1"/></td></tr> |
---|
541 | <tr><td class="small">Report generated at <xsl:value-of select="date:date-time()"/></td></tr> |
---|
542 | </table> |
---|
543 | </xsl:template> |
---|
544 | |
---|
545 | <!-- class header --> |
---|
546 | <xsl:template name="testsuite.test.header"> |
---|
547 | <tr valign="top"> |
---|
548 | <th width="80%">Name</th> |
---|
549 | <th>Tests</th> |
---|
550 | <th>Errors</th> |
---|
551 | <th>Failures</th> |
---|
552 | <th nowrap="nowrap">Time(s)</th> |
---|
553 | </tr> |
---|
554 | </xsl:template> |
---|
555 | |
---|
556 | <!-- method header --> |
---|
557 | <xsl:template name="testcase.test.header"> |
---|
558 | <tr valign="top"> |
---|
559 | <th>Name</th> |
---|
560 | <th>Status</th> |
---|
561 | <th width="80%">Type</th> |
---|
562 | <th nowrap="nowrap">Time(s)</th> |
---|
563 | </tr> |
---|
564 | </xsl:template> |
---|
565 | |
---|
566 | |
---|
567 | <!-- class information --> |
---|
568 | <xsl:template match="testsuite" mode="print.test"> |
---|
569 | <tr valign="top"> |
---|
570 | <xsl:attribute name="class"> |
---|
571 | <xsl:choose> |
---|
572 | <xsl:when test="@errors[.> 0]">Error</xsl:when> |
---|
573 | <xsl:when test="@failures[.> 0]">Failure</xsl:when> |
---|
574 | <xsl:otherwise>Pass</xsl:otherwise> |
---|
575 | </xsl:choose> |
---|
576 | </xsl:attribute> |
---|
577 | <td><a href="{@name}.html"><xsl:value-of select="@name"/></a></td> |
---|
578 | <td><xsl:apply-templates select="@tests"/></td> |
---|
579 | <td><xsl:apply-templates select="@errors"/></td> |
---|
580 | <td><xsl:apply-templates select="@failures"/></td> |
---|
581 | <td><xsl:call-template name="display-time"> |
---|
582 | <xsl:with-param name="value" select="@time"/> |
---|
583 | </xsl:call-template> |
---|
584 | </td> |
---|
585 | </tr> |
---|
586 | </xsl:template> |
---|
587 | |
---|
588 | <xsl:template match="testcase" mode="print.test"> |
---|
589 | <tr valign="top"> |
---|
590 | <xsl:attribute name="class"> |
---|
591 | <xsl:choose> |
---|
592 | <xsl:when test="error">Error</xsl:when> |
---|
593 | <xsl:when test="failure">Failure</xsl:when> |
---|
594 | <xsl:otherwise>TableRowColor</xsl:otherwise> |
---|
595 | </xsl:choose> |
---|
596 | </xsl:attribute> |
---|
597 | <td><xsl:value-of select="@name"/></td> |
---|
598 | <xsl:choose> |
---|
599 | <xsl:when test="failure"> |
---|
600 | <td>Failure</td> |
---|
601 | <td><xsl:apply-templates select="failure"/></td> |
---|
602 | </xsl:when> |
---|
603 | <xsl:when test="error"> |
---|
604 | <td>Error</td> |
---|
605 | <td><xsl:apply-templates select="error"/></td> |
---|
606 | </xsl:when> |
---|
607 | <xsl:otherwise> |
---|
608 | <td>Success</td> |
---|
609 | <td></td> |
---|
610 | </xsl:otherwise> |
---|
611 | </xsl:choose> |
---|
612 | <td> |
---|
613 | <xsl:call-template name="display-time"> |
---|
614 | <xsl:with-param name="value" select="@time"/> |
---|
615 | </xsl:call-template> |
---|
616 | </td> |
---|
617 | </tr> |
---|
618 | </xsl:template> |
---|
619 | |
---|
620 | |
---|
621 | <!-- Note : the below template error and failure are the same style |
---|
622 | so just call the same style store in the toolkit template --> |
---|
623 | <xsl:template match="failure"> |
---|
624 | <xsl:call-template name="display-failures"/> |
---|
625 | </xsl:template> |
---|
626 | |
---|
627 | <xsl:template match="error"> |
---|
628 | <xsl:call-template name="display-failures"/> |
---|
629 | </xsl:template> |
---|
630 | |
---|
631 | <!-- Style for the error and failure in the testcase template --> |
---|
632 | <xsl:template name="display-failures"> |
---|
633 | <xsl:choose> |
---|
634 | <xsl:when test="not(@message)">N/A</xsl:when> |
---|
635 | <xsl:otherwise> |
---|
636 | <xsl:value-of select="@message"/> |
---|
637 | </xsl:otherwise> |
---|
638 | </xsl:choose> |
---|
639 | <!-- display the stacktrace --> |
---|
640 | <br/><br/> |
---|
641 | <code> |
---|
642 | <xsl:call-template name="br-replace"> |
---|
643 | <xsl:with-param name="word" select="."/> |
---|
644 | </xsl:call-template> |
---|
645 | </code> |
---|
646 | </xsl:template> |
---|
647 | |
---|
648 | <!-- |
---|
649 | template that will convert a carriage return into a br tag |
---|
650 | @param word the text from which to convert CR to BR tag |
---|
651 | --> |
---|
652 | <xsl:template name="br-replace"> |
---|
653 | <xsl:param name="word"/> |
---|
654 | <xsl:choose> |
---|
655 | <xsl:when test="contains($word,'
')"> |
---|
656 | <xsl:value-of select="substring-before($word,'
')"/> |
---|
657 | <br /> |
---|
658 | <xsl:call-template name="br-replace"> |
---|
659 | <xsl:with-param name="word" select="substring-after($word,'
')"/> |
---|
660 | </xsl:call-template> |
---|
661 | </xsl:when> |
---|
662 | <xsl:otherwise> |
---|
663 | <xsl:value-of select="$word"/> |
---|
664 | </xsl:otherwise> |
---|
665 | </xsl:choose> |
---|
666 | </xsl:template> |
---|
667 | |
---|
668 | <xsl:template name="display-time"> |
---|
669 | <xsl:param name="value"/> |
---|
670 | <xsl:value-of select="format-number($value,'0.000')"/> |
---|
671 | </xsl:template> |
---|
672 | |
---|
673 | <xsl:template name="display-percent"> |
---|
674 | <xsl:param name="value"/> |
---|
675 | <xsl:value-of select="format-number($value,'0.00%')"/> |
---|
676 | </xsl:template> |
---|
677 | </xsl:stylesheet> |
---|
678 | |
---|