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