test/test-automation/style.xsl
author Markus Kauppila
Wed, 06 Jul 2011 23:49:36 +0300
changeset 5748 91a7152856f3
parent 5739 be70f1dfd7aa
child 5755 35d4ae5dea90
permissions -rw-r--r--
Made the default XSL style less blocky.
     1 <?xml version="1.0" encoding="ISO-8859-1"?>
     2 <xsl:stylesheet version="1.0" 
     3 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     4 
     5 <xsl:template match="/">
     6 	
     7 <html>
     8 <head>
     9 <title>Test report</title>
    10 
    11 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"/>
    12 
    13 <script type="text/javascript">
    14 
    15 var hideTests = '[Hide tests]';
    16 var showTests = '[Show tests]';
    17 
    18 var hideAsserts = '[Hide Assert Summary]';
    19 var showAsserts = '[Show Assert Summary]';
    20 
    21 var hideAllTests = '[Hide All Tests]';
    22 var showAllTests = '[Show All Tests]';
    23 
    24 var hideEverything = '[Hide Everything]';
    25 var showEverything = '[Show Everything]';
    26 
    27 var animationSpeed = 'fast';
    28 
    29 $(document).ready(function() {
    30 	$("span.show-tests").click(function() {
    31 		var content = $(this).html();
    32 		var id = $(this).attr('uid');
    33 		var searchString = "div.tests[uid="+id+"]";
    34 	
    35 		if(content == hideTests) {
    36 			$(searchString).hide(animationSpeed);
    37 			$(this).text(showTests);
    38 		} else {
    39 			$(searchString).show(animationSpeed);
    40 			$(this).text(hideTests);
    41 		}
    42 	});
    43 
    44 	$("span.show-asserts").click(function() {
    45 		var content = $(this).html();
    46 		var id = $(this).attr('uid');
    47 		var searchString = "div.asserts[uid="+id+"]";
    48 		
    49 		if(content == hideAsserts) {
    50 			$(searchString).hide(animationSpeed);
    51 			$(this).text(showAsserts);
    52 		} else {
    53 			$(searchString).show(animationSpeed);
    54 			$(this).text(hideAsserts);
    55 		}
    56 	});
    57 	
    58 	$("span.show-all-tests").click(function() {
    59 		var content = $(this).html();
    60 		var searchString = "div.tests";
    61 		
    62 		if(content == hideAllTests) {
    63 			$(searchString).hide(animationSpeed);
    64 			$(this).text(showAllTests);
    65 			
    66 			/* handle the individual '[show tests]' switcher */
    67 			$("span.show-tests[uid]").text(showTests);
    68 		} else {
    69 			$(searchString).show(animationSpeed);
    70 			$(this).text(hideAllTests);
    71 			
    72 			/* handle the individual '[show tests]' switcher */
    73 			$("span.show-tests[uid]").text(hideTests);
    74 		}
    75 	});
    76 	
    77 	$("span.show-everything").click(function() {
    78 		var content = $(this).html();
    79 		var searchString = "div.tests";
    80 		
    81 		if(content == hideEverything) {
    82 			$("div.tests").hide(animationSpeed);
    83 			$("div.asserts").hide(animationSpeed);
    84 			$(this).text(showEverything);
    85 			
    86 			/* handle the individual switchers */
    87 			$("span.show-tests[uid]").text(showTests);
    88 			$("span.show-asserts[uid]").text(showAsserts);
    89 		} else {
    90 			$("div.tests").show(animationSpeed);
    91 			$("div.asserts").show(animationSpeed);
    92 			$(this).text(hideEverything);
    93 			
    94 			/* handle the individual switchers */
    95 			$("span.show-tests[uid]").text(hideTests);
    96 			$("span.show-asserts[uid]").text(hideAsserts);
    97 		}
    98 	});
    99 
   100 	/* Initially everything is hidden */
   101 	$("div.tests").hide();
   102 	$("div.asserts").hide();
   103 	
   104 	/* Color the tests based on the result */
   105 	$("span.testResult[result='passed']").addClass('passed');
   106 	$("span.testResult[result='failed']").addClass('failed');
   107 	
   108 	/* Color the asserts based on the result */
   109 	$("span.assertResult[result='pass']").addClass('passed');
   110 	$("span.assertResult[result='failure']").addClass('failed');
   111 });
   112 
   113 </script>
   114 <style>
   115 
   116 div, h1 {
   117   padding: 2px 10px 2px 10px;
   118   margin: 5px 0px 5px 0px;
   119 }
   120 
   121 .assert {
   122   padding: 0px 10px 0px 10px;
   123   margin: 0px 0px 0px 0px;
   124 }
   125 
   126 .document {
   127   font-family: Arial;
   128   font-size: 11pt;
   129   background-color: #EDEDED;
   130 }
   131 	
   132 .description {
   133   font-style: italic;
   134 }	
   135 	
   136 .bigtitle {
   137   font-size: 14pt;
   138   font-weight: bold;
   139 }
   140 	
   141 .title {
   142   font-weight: bold;
   143 }
   144 	
   145 .switch {
   146   font-style: italic;
   147   color: rgb(10, 10, 200); 
   148   font-size: 10pt;
   149   cursor: pointer;
   150 }	
   151 	
   152 .passed {
   153  color: green;
   154 }
   155 
   156 .failed {
   157  color: red;
   158 }
   159 
   160 </style>
   161 
   162 </head>
   163 <body class="document">
   164   <h1>Test Report</h1>
   165   <div>
   166     <span class="title">Start time: </span><xsl:value-of select="testlog/startTime"/><br/>
   167     <!-- and ended at <xsl:value-of select="testlog/endTime"/>.<br/>-->
   168     <span class="title">Total runtime: </span><xsl:value-of select="testlog/totalRuntime"/> seconds.<br/>
   169     <span class="title">Harness parameters: </span>
   170 	<span xml:space="preserve">
   171       <xsl:for-each select="testlog/parameters/parameter">
   172         <xsl:value-of select="."/> 	 
   173       </xsl:for-each>
   174     </span>
   175 	<br/>
   176     <span class="title">Statistics:</span><br/>
   177     <div class="statistics">
   178       <span>Executed </span> <xsl:value-of select="testlog/numSuites"/> test suites. <br/>
   179       <span>Tests in total: </span> <xsl:value-of select="testlog/numTests"/> (passed: <xsl:value-of select="testlog/numPassedTests"/>, failed: <xsl:value-of select="testlog/numFailedTests"/>)
   180     </div>
   181   </div>
   182 
   183   <div>
   184 	<br/>
   185 	<span class="bigtitle">Test Results</span><br/>
   186     <span class="switch show-all-tests">[Show All Tests] </span> | 
   187     <span class="switch show-everything">[Show Everything]</span>
   188   </div>
   189 	<br/>
   190 	
   191   <xsl:for-each select="testlog/suite">
   192     <div id="suite">
   193     Suite: <span class="title"> <xsl:value-of select="name"/></span> (<xsl:value-of select="startTime"/>)
   194 	<div class="suiteInfo">
   195 		Tests: passed <xsl:value-of select="testsPassed"/>, failed <xsl:value-of select="testsFailed"/>, skipped <xsl:value-of select="testsSkipped"/>.<br/>
   196 		Total runtime: <xsl:value-of select="totalRuntime"/> seconds. <br/>
   197 		<span class="show-tests switch" uid="{generate-id(test)}">[Show tests]</span>
   198         <div class="tests" uid="{generate-id(test)}">
   199 	      <xsl:for-each select="test">
   200 			<div class="test">
   201 			Test <span class="title"><xsl:value-of select="name"/>: </span>
   202 			<span class="testResult">
   203 			  <xsl:attribute name="result">
   204 			    <xsl:value-of select="result"/> 
   205 	           </xsl:attribute><xsl:value-of select="result"/> 
   206 	        </span> 
   207 			(Total runtime: <xsl:value-of select="totalRuntime"/> seconds)<br/>
   208 			Description: <span class="description"> <xsl:value-of select="description"/> </span><br/>
   209 		      <span class="switch show-asserts" uid="{generate-id(assertSummary)}">[Show Assert Summary]</span><br/>
   210 			  <div class="asserts" uid="{generate-id(assertSummary)}">
   211 		        <xsl:for-each select="assert"> 
   212 			      <div class="assert">
   213 					<xsl:value-of select="name"/>: 
   214 					<span class="assertResult">
   215 						<xsl:attribute name="result">
   216 					      <xsl:value-of select="result"/>
   217 					    </xsl:attribute>
   218 					  <xsl:value-of select="result"/>  
   219 					</span>.
   220 					 Message: <span class="description"><xsl:value-of select="message"/></span>
   221 		          </div>
   222 		        </xsl:for-each>
   223 				Asserts in total: <xsl:value-of select="assertSummary/assertCount"/> (passed: <xsl:value-of select="assertSummary/assertsPassed"/>, failed: <xsl:value-of select="assertSummary/assertsFailed"/>)
   224 		      </div>
   225     		</div>
   226 		  </xsl:for-each>
   227 	    </div>
   228 	</div>
   229   </div>
   230   </xsl:for-each>
   231   <br/>
   232 </body>
   233 </html>
   234 
   235 </xsl:template>
   236 </xsl:stylesheet>
   237