1<?xml version="1.0"?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 3 xmlns="http://www.w3.org/1999/xhtml" 4 xmlns:stringutils="xalan://org.apache.tools.ant.util.StringUtils" 5 exclude-result-prefixes="stringutils"> 6<xsl:output method="xml" indent="yes" encoding="UTF-8" 7 doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" 8 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/> 9<xsl:decimal-format decimal-separator="." grouping-separator="," /> 10<!-- 11 Licensed to the Apache Software Foundation (ASF) under one or more 12 contributor license agreements. See the NOTICE file distributed with 13 this work for additional information regarding copyright ownership. 14 The ASF licenses this file to You under the Apache License, Version 2.0 15 (the "License"); you may not use this file except in compliance with 16 the License. You may obtain a copy of the License at 17 18 http://www.apache.org/licenses/LICENSE-2.0 19 20 Unless required by applicable law or agreed to in writing, software 21 distributed under the License is distributed on an "AS IS" BASIS, 22 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 See the License for the specific language governing permissions and 24 limitations under the License. 25 --> 26 27<xsl:param name="qualified.bundle.version"/> 28<xsl:param name="jacoco.home.url"/> 29<xsl:param name="copyright.years"/> 30 31<!-- 32 33 JaCoCo test report stylesheet. 34 35--> 36<xsl:template match="testsuites"> 37 <html> 38 <head> 39 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 40 <link rel="stylesheet" href="../doc/resources/doc.css" charset="UTF-8" type="text/css" /> 41 <link rel="shortcut icon" href="../doc/resources/report.gif" type="image/gif" /> 42 <title>JaCoCo - JUnit Test Results</title> 43 44 <style type="text/css"> 45 .Error { 46 font-weight:bold; color:red; 47 } 48 .Failure { 49 font-weight:bold; color:purple; 50 } 51 </style> 52 </head> 53 <body> 54 <div id="content"> 55 <a name="top"></a> 56 <xsl:call-template name="pageHeader"/> 57 58 <!-- Summary part --> 59 <xsl:call-template name="summary"/> 60 61 <!-- Package List part --> 62 <xsl:call-template name="packagelist"/> 63 64 <!-- For each package create its part --> 65 <xsl:call-template name="packages"/> 66 67 <!-- For each class create the part --> 68 <xsl:call-template name="classes"/> 69 70 </div> 71 <div class="footer"> 72 <span class="right"><a href="{$jacoco.home.url}">JaCoCo</a> <xsl:value-of select="$qualified.bundle.version"/></span> 73 <a href="../doc/license.html">Copyright</a> © <xsl:value-of select="$copyright.years"/> Mountainminds GmbH & Co. KG and Contributors 74 </div> 75 </body> 76 </html> 77</xsl:template> 78 79 80 81<!-- ================================================================== --> 82<!-- Write a list of all packages with an hyperlink to the anchor of --> 83<!-- of the package name. --> 84<!-- ================================================================== --> 85<xsl:template name="packagelist"> 86 <h2>Packages</h2> 87 <table class="coverage"> 88 <xsl:call-template name="testsuite.test.header"/> 89 <tbody> 90 <!-- list all packages recursively --> 91 <xsl:for-each select="./testsuite[not(./@package = preceding-sibling::testsuite/@package)]"> 92 <xsl:sort select="@package"/> 93 <xsl:variable name="testsuites-in-package" select="/testsuites/testsuite[./@package = current()/@package]"/> 94 <xsl:variable name="testCount" select="sum($testsuites-in-package/@tests)"/> 95 <xsl:variable name="errorCount" select="sum($testsuites-in-package/@errors)"/> 96 <xsl:variable name="failureCount" select="sum($testsuites-in-package/@failures)"/> 97 <xsl:variable name="timeCount" select="sum($testsuites-in-package/@time)"/> 98 99 <!-- write a summary for the package --> 100 <tr valign="top"> 101 <!-- set a nice color depending if there is an error/failure --> 102 <xsl:attribute name="class"> 103 <xsl:choose> 104 <xsl:when test="$failureCount > 0">Failure</xsl:when> 105 <xsl:when test="$errorCount > 0">Error</xsl:when> 106 </xsl:choose> 107 </xsl:attribute> 108 <td style="width:24em"><a href="#{@package}" class="el_testsuite"><xsl:value-of select="@package"/></a></td> 109 <td><xsl:value-of select="$testCount"/></td> 110 <td><xsl:value-of select="$errorCount"/></td> 111 <td><xsl:value-of select="$failureCount"/></td> 112 <td> 113 <xsl:call-template name="display-time"> 114 <xsl:with-param name="value" select="$timeCount"/> 115 </xsl:call-template> 116 </td> 117 </tr> 118 </xsl:for-each> 119 </tbody> 120 </table> 121 <p class="hint"> 122 Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers. 123 </p> 124</xsl:template> 125 126 127 <!-- ================================================================== --> 128 <!-- Write a package level report --> 129 <!-- It creates a table with values from the document: --> 130 <!-- Name | Tests | Errors | Failures | Time --> 131 <!-- ================================================================== --> 132 <xsl:template name="packages"> 133 <!-- create an anchor to this package name --> 134 <xsl:for-each select="/testsuites/testsuite[not(./@package = preceding-sibling::testsuite/@package)]"> 135 <xsl:sort select="@package"/> 136 <a name="{@package}"></a> 137 <h3>Package <xsl:value-of select="@package"/></h3> 138 139 <table class="coverage"> 140 <xsl:call-template name="testsuite.test.header"/> 141 142 <!-- match the testsuites of this package --> 143 <xsl:apply-templates select="/testsuites/testsuite[./@package = current()/@package]" mode="print.test"/> 144 </table> 145 <p> 146 <a href="#top">Back to top</a> 147 </p> 148 </xsl:for-each> 149 </xsl:template> 150 151 <xsl:template name="classes"> 152 <xsl:for-each select="testsuite"> 153 <xsl:sort select="@name"/> 154 <!-- create an anchor to this class name --> 155 <a name="{@name}"></a> 156 <h3>TestCase <xsl:value-of select="@name"/></h3> 157 158 <table class="coverage"> 159 <xsl:call-template name="testcase.test.header"/> 160 <!-- 161 test can even not be started at all (failure to load the class) 162 so report the error directly 163 --> 164 <xsl:if test="./error"> 165 <tr class="Error"> 166 <td colspan="4"><xsl:apply-templates select="./error"/></td> 167 </tr> 168 </xsl:if> 169 <xsl:apply-templates select="./testcase" mode="print.test"/> 170 </table> 171 <p> 172 <a href="#top">Back to top</a> 173 </p> 174 </xsl:for-each> 175 </xsl:template> 176 177<xsl:template name="summary"> 178 <h2>Summary</h2> 179 <xsl:variable name="testCount" select="sum(testsuite/@tests)"/> 180 <xsl:variable name="errorCount" select="sum(testsuite/@errors)"/> 181 <xsl:variable name="failureCount" select="sum(testsuite/@failures)"/> 182 <xsl:variable name="timeCount" select="sum(testsuite/@time)"/> 183 <xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/> 184 <table class="coverage"> 185 <thead> 186 <tr valign="top"> 187 <td>Tests</td> 188 <td>Failures</td> 189 <td>Errors</td> 190 <td>Success rate</td> 191 <td>Time</td> 192 </tr> 193 </thead> 194 <tbody> 195 <tr valign="top"> 196 <xsl:attribute name="class"> 197 <xsl:choose> 198 <xsl:when test="$failureCount > 0">Failure</xsl:when> 199 <xsl:when test="$errorCount > 0">Error</xsl:when> 200 </xsl:choose> 201 </xsl:attribute> 202 <td><xsl:value-of select="$testCount"/></td> 203 <td><xsl:value-of select="$failureCount"/></td> 204 <td><xsl:value-of select="$errorCount"/></td> 205 <td> 206 <xsl:call-template name="display-percent"> 207 <xsl:with-param name="value" select="$successRate"/> 208 </xsl:call-template> 209 </td> 210 <td> 211 <xsl:call-template name="display-time"> 212 <xsl:with-param name="value" select="$timeCount"/> 213 </xsl:call-template> 214 </td> 215 </tr> 216 </tbody> 217 </table> 218 <p class="hint"> 219 Note: <i>failures</i> are anticipated and checked for with assertions while <i>errors</i> are unanticipated. 220 </p> 221</xsl:template> 222 223<!-- Page HEADER --> 224<xsl:template name="pageHeader"> 225 <div class="breadcrumb"> 226 <a href="../index.html" class="el_report">JaCoCo</a> > 227 <span class="el_testsuite">JUnit Test Results</span> 228 </div> 229 <h1>JUnit Test Results</h1> 230</xsl:template> 231 232<xsl:template match="testsuite" mode="header"> 233 <thead> 234 <tr valign="top"> 235 <td>Name</td> 236 <td>Tests</td> 237 <td>Errors</td> 238 <td>Failures</td> 239 <td nowrap="nowrap">Time(s)</td> 240 </tr> 241 </thead> 242</xsl:template> 243 244<!-- class header --> 245<xsl:template name="testsuite.test.header"> 246 <thead> 247 <tr> 248 <td>Name</td> 249 <td>Tests</td> 250 <td>Errors</td> 251 <td>Failures</td> 252 <td>Time(s)</td> 253 </tr> 254 </thead> 255</xsl:template> 256 257<!-- method header --> 258<xsl:template name="testcase.test.header"> 259 <thead> 260 <tr> 261 <td>Name</td> 262 <td>Status</td> 263 <td>Type</td> 264 <td>Time(s)</td> 265 </tr> 266 </thead> 267</xsl:template> 268 269 270<!-- class information --> 271<xsl:template match="testsuite" mode="print.test"> 272 <tr valign="top"> 273 <!-- set a nice color depending if there is an error/failure --> 274 <xsl:attribute name="class"> 275 <xsl:choose> 276 <xsl:when test="@failures[.> 0]">Failure</xsl:when> 277 <xsl:when test="@errors[.> 0]">Error</xsl:when> 278 </xsl:choose> 279 </xsl:attribute> 280 281 <!-- print testsuite information --> 282 <td style="width:24em"><a href="#{@name}" class="el_testsuite"><xsl:value-of select="@name"/></a></td> 283 <td><xsl:value-of select="@tests"/></td> 284 <td><xsl:value-of select="@errors"/></td> 285 <td><xsl:value-of select="@failures"/></td> 286 <td> 287 <xsl:call-template name="display-time"> 288 <xsl:with-param name="value" select="@time"/> 289 </xsl:call-template> 290 </td> 291 </tr> 292</xsl:template> 293 294<xsl:template match="testcase" mode="print.test"> 295 <tr valign="top"> 296 <xsl:attribute name="class"> 297 <xsl:choose> 298 <xsl:when test="failure | error">Error</xsl:when> 299 </xsl:choose> 300 </xsl:attribute> 301 <td style="width:24em"><span class="el_test"><xsl:value-of select="@name"/></span></td> 302 <xsl:choose> 303 <xsl:when test="failure"> 304 <td>Failure</td> 305 <td><xsl:apply-templates select="failure"/></td> 306 </xsl:when> 307 <xsl:when test="error"> 308 <td>Error</td> 309 <td><xsl:apply-templates select="error"/></td> 310 </xsl:when> 311 <xsl:otherwise> 312 <td>Success</td> 313 <td></td> 314 </xsl:otherwise> 315 </xsl:choose> 316 <td> 317 <xsl:call-template name="display-time"> 318 <xsl:with-param name="value" select="@time"/> 319 </xsl:call-template> 320 </td> 321 </tr> 322</xsl:template> 323 324 325<xsl:template match="failure"> 326 <xsl:call-template name="display-failures"/> 327</xsl:template> 328 329<xsl:template match="error"> 330 <xsl:call-template name="display-failures"/> 331</xsl:template> 332 333<!-- Style for the error and failure in the tescase template --> 334<xsl:template name="display-failures"> 335 <xsl:choose> 336 <xsl:when test="not(@message)">N/A</xsl:when> 337 <xsl:otherwise> 338 <xsl:value-of select="@message"/> 339 </xsl:otherwise> 340 </xsl:choose> 341 <!-- display the stacktrace --> 342 <code> 343 <br/><br/> 344 <xsl:call-template name="br-replace"> 345 <xsl:with-param name="word" select="."/> 346 </xsl:call-template> 347 </code> 348 <!-- the later is better but might be problematic for non-21" monitors... --> 349 <!--pre><xsl:value-of select="."/></pre--> 350</xsl:template> 351 352<xsl:template name="JS-escape"> 353 <xsl:param name="string"/> 354 <xsl:param name="tmp1" select="stringutils:replace(string($string),'\','\\')"/> 355 <xsl:param name="tmp2" select="stringutils:replace(string($tmp1),"'","\'")"/> 356 <xsl:value-of select="$tmp2"/> 357</xsl:template> 358 359 360<!-- 361 template that will convert a carriage return into a br tag 362 @param word the text from which to convert CR to BR tag 363--> 364<xsl:template name="br-replace"> 365 <xsl:param name="word"/> 366 <xsl:value-of disable-output-escaping="yes" select='stringutils:replace(string($word),"
","<br/>")'/> 367</xsl:template> 368 369<xsl:template name="display-time"> 370 <xsl:param name="value"/> 371 <xsl:value-of select="format-number($value,'0.000')"/> 372</xsl:template> 373 374<xsl:template name="display-percent"> 375 <xsl:param name="value"/> 376 <xsl:value-of select="format-number($value,'0.00%')"/> 377</xsl:template> 378 379</xsl:stylesheet> 380