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