PHP Unit Testing Framework 1
A Unit testing framework for PHP.

text_test_runner.php

Go to the documentation of this file.
00001 <?php
00035 
00036 require_once 'xml_test_runner_with_style_sheet.php';
00037 
00045 class TextTestRunner extends XMLTestRunnerWithStyleSheet
00046 {
00053   public function __construct()
00054   {
00055     parent::__construct();
00056     $this->styleSheet .= <<<END_OF_STYLE_SHEET
00057 <xsl:output method="text" />
00058 <xsl:template match="/testresults">
00059 <xsl:text>
00060 ******************************************************************************
00061 *                                                                            *
00062 *                                TEST REPORT                                 *
00063 *                                                                            *
00064 ******************************************************************************
00065 
00066 +----------------------------------------------------------------------------+
00067 |                                   SUMMARY                                  |
00068 +----------------------------------------------------------------------------+
00069 </xsl:text>
00070 <xsl:for-each select="testcase">
00071 <xsl:text>
00072 
00073 Name: </xsl:text><xsl:value-of select="name"/>
00074 <xsl:text>
00075 Test ID: </xsl:text><xsl:value-of select="id"/>
00076 <xsl:text>
00077 Description:
00078 </xsl:text>
00079 <xsl:value-of select="description"/>
00080 <xsl:text>
00081 Test Passed: </xsl:text>
00082 <xsl:if test="passed='Yes'">Passed</xsl:if>
00083 <xsl:if test="passed='No'">Failed</xsl:if> 
00084 </xsl:for-each>
00085 <xsl:text>
00086 
00087 +----------------------------------------------------------------------------+
00088 |                                   DETAILS                                  |
00089 +----------------------------------------------------------------------------+
00090 
00091 </xsl:text>
00092 <xsl:for-each select="testcase">
00093 <xsl:text>
00094 Name: </xsl:text>
00095 <xsl:value-of select="name"/>
00096 <xsl:text>
00097 Test ID: </xsl:text>
00098 <xsl:value-of select="id"/>
00099 <xsl:text>
00100 Test Passed: </xsl:text>
00101 <xsl:if test="passed='Yes'"><xsl:text>Passed</xsl:text></xsl:if>
00102 <xsl:if test="passed='No'"><xsl:text>Failed</xsl:text></xsl:if>
00103 
00104 <xsl:text>
00105                                   TEST EVENTS
00106                                   -----------
00107 
00108 </xsl:text>
00109 <xsl:for-each select="listOfEvents/event">
00110 <xsl:text>
00111 </xsl:text>
00112 
00113 <xsl:value-of select="time" />
00114 <xsl:text>
00115 </xsl:text>
00116 
00117 <xsl:choose>
00118 
00119 <xsl:when test="type='PASS'">
00120 <xsl:text>Test step success
00121 Reason: </xsl:text>
00122 <xsl:value-of select="reason" />
00123 <xsl:text>
00124 Message: </xsl:text>
00125 <xsl:value-of select="message" />
00126 <xsl:text>
00127 Actual value type:
00128 </xsl:text>
00129 <xsl:value-of select="actual/type" />
00130 <xsl:text>
00131 Actual value:
00132 </xsl:text>
00133 <xsl:value-of select="actual/value" />
00134 <xsl:text>
00135 Comparison value type:
00136 </xsl:text>
00137 <xsl:value-of select="comparison/type" />
00138 <xsl:text>
00139 Comparison value:
00140 </xsl:text>
00141 <xsl:value-of select="comparison/value" />
00142 <xsl:text>
00143 File: </xsl:text>
00144 <xsl:value-of select="file" />
00145 <xsl:text> at line </xsl:text>
00146 <xsl:value-of select="line" />
00147 <xsl:text>
00148 </xsl:text>
00149 </xsl:when>
00150 
00151 <xsl:when test="type='PASS_MSG'">
00152 <xsl:text>Test step success
00153 Message: </xsl:text>
00154 <xsl:value-of select="message" />
00155 <xsl:text>
00156 File: </xsl:text>
00157 <xsl:value-of select="file" />
00158 <xsl:text> at line </xsl:text>
00159 <xsl:value-of select="line" />
00160 <xsl:text>
00161 </xsl:text>
00162 </xsl:when>
00163 
00164 <xsl:when test="type='FAIL'">
00165 <xsl:text>Test step failed
00166 Reason: </xsl:text>
00167 <xsl:value-of select="reason" />
00168 <xsl:text>
00169 Message: </xsl:text>
00170 <xsl:value-of select="message" />
00171 <xsl:text>
00172 Actual value type:
00173 </xsl:text>
00174 <xsl:value-of select="actual/type" />
00175 <xsl:text>
00176 Actual value:
00177 </xsl:text>
00178 <xsl:value-of select="actual/value" />
00179 <xsl:text>
00180 Comparison value type:
00181 </xsl:text>
00182 <xsl:value-of select="comparison/type" />
00183 <xsl:text>
00184 Comparison value:
00185 </xsl:text>
00186 <xsl:value-of select="comparison/value" />
00187 <xsl:text>
00188 File: </xsl:text>
00189 <xsl:value-of select="file" />
00190 <xsl:text> at line </xsl:text>
00191 <xsl:value-of select="line" />
00192 <xsl:text>
00193 </xsl:text>
00194 </xsl:when>
00195 
00196 <xsl:when test="type='FAIL_MSG'">
00197 <xsl:text>Test step failed
00198 Message: </xsl:text>
00199 <xsl:value-of select="message" />
00200 <xsl:text>
00201 File: </xsl:text>
00202 <xsl:value-of select="file" />
00203 <xsl:text> at line </xsl:text>
00204 <xsl:value-of select="line" />
00205 <xsl:text>
00206 </xsl:text>
00207 </xsl:when>
00208 
00209 <xsl:when test="type='ERROR'">
00210 <xsl:text>Test step in error
00211 Reason: </xsl:text>
00212 <xsl:value-of select="reason" />
00213 <xsl:text>
00214 Message: </xsl:text>
00215 <xsl:value-of select="message" />
00216 <xsl:text>
00217 Actual value type:
00218 </xsl:text>
00219 <xsl:value-of select="actual/type" />
00220 <xsl:text>
00221 Actual value:
00222 </xsl:text>
00223 <xsl:value-of select="actual/value" />
00224 <xsl:text>
00225 Comparison value type:
00226 </xsl:text>
00227 <xsl:value-of select="comparison/type" />
00228 <xsl:text>
00229 Comparison value:
00230 </xsl:text>
00231 <xsl:value-of select="comparison/value" />
00232 <xsl:text>
00233 File: </xsl:text>
00234 <xsl:value-of select="file" />
00235 <xsl:text>at line </xsl:text>
00236 <xsl:value-of select="line" />
00237 <xsl:text>
00238 </xsl:text>
00239 </xsl:when>
00240 
00241 <xsl:when test="type='USER_MSG'">
00242 <xsl:text>Message: </xsl:text>
00243 <xsl:value-of select="message" />
00244 <xsl:text>
00245 File: </xsl:text>
00246 <xsl:value-of select="file" />
00247 <xsl:text> at line </xsl:text>
00248 <xsl:value-of select="line" />
00249 <xsl:text>
00250 </xsl:text>
00251 </xsl:when>
00252 
00253 <xsl:when test="type='SYS_MSG'">
00254 <xsl:value-of select="reason" /><xsl:text>
00255 </xsl:text>
00256 </xsl:when>
00257 
00258 <xsl:when test="type='EXCEPTION_THROWN'">
00259 <xsl:text>Exception occured at: </xsl:text>
00260 <xsl:value-of select="message" />
00261 <xsl:text>
00262 Exceptions details: </xsl:text>
00263 <xsl:value-of select="reason" />
00264 <xsl:text>
00265 File: </xsl:text>
00266 <xsl:value-of select="file" />
00267 <xsl:text> at line </xsl:text>
00268 <xsl:value-of select="line" />
00269 <xsl:text>
00270 </xsl:text>
00271 </xsl:when>
00272 
00273 <xsl:when test="type='START_SETUP'">
00274 <xsl:text>Set up phase started.
00275 </xsl:text>
00276 </xsl:when>
00277 
00278 <xsl:when test="type='END_SETUP'">
00279 <xsl:text>Set up phase finished.
00280 </xsl:text>
00281 </xsl:when>
00282 <xsl:when test="type='START_RUN'">
00283 <xsl:text>Run phase started.
00284 </xsl:text>
00285 </xsl:when>
00286 
00287 <xsl:when test="type='END_RUN'">
00288 <xsl:text>Run phase finished.
00289 </xsl:text>
00290 </xsl:when>
00291 
00292 <xsl:when test="type='START_TEAR_DOWN'">
00293 <xsl:text>Tear down phase started.
00294 </xsl:text>
00295 </xsl:when>
00296 
00297 <xsl:when test="type='END_TEAR_DOWN'">
00298 <xsl:text>Tear down phase finished.
00299 </xsl:text>
00300 </xsl:when>
00301 
00302 </xsl:choose>
00303 
00304 </xsl:for-each>
00305 <xsl:text>
00306 ==============================================================================
00307 </xsl:text>
00308 
00309 </xsl:for-each>
00310 </xsl:template>
00311 </xsl:stylesheet>  
00312 END_OF_STYLE_SHEET;
00313 
00314   }
00315   
00332   public function Run(TestSuite &$suite,
00333                       $filename = null,
00334                       $extension = 'txt')
00335   {
00336     return parent::Run($suite, $filename, $extension);
00337   }
00338 }
00339 ?>
 All Data Structures Files Functions Variables

© 2011, Ed Heal