Skip to content
This repository
Browse code

ENHANCEMENT TestReporter now reports incomplete tests properly

  • Loading branch information...
commit fc18b2c78879d8bad8d8be509b8842dcd9350792 1 parent 0e31846
Sean Harvey authored April 14, 2012
29  dev/CliTestReporter.php
@@ -14,12 +14,19 @@ public function writeResults() {
14 14
 		$passCount = 0;
15 15
 		$failCount = 0;
16 16
 		$testCount = 0;
  17
+		$incompleteCount = 0;
17 18
 		$errorCount = 0;
18  
-		
  19
+
19 20
 		foreach($this->suiteResults['suites'] as $suite) {
20 21
 			foreach($suite['tests'] as $test) {
21 22
 				$testCount++;
22  
-				($test['status'] == 1) ? $passCount++ : $failCount++;
  23
+				if($test['status'] == 2) {
  24
+					$incompleteCount++;
  25
+				} elseif($test['status'] === 1) {
  26
+					$passCount++;
  27
+				} else {
  28
+					$failCount++;
  29
+				}
23 30
 			}
24 31
 		}
25 32
 		
@@ -29,8 +36,9 @@ public function writeResults() {
29 36
 		}  else {
30 37
 			echo SS_Cli::text(" AT LEAST ONE FAILURE ", "white", "red");
31 38
 		}
32  
-		echo "\n\n$testCount tests run: " . SS_Cli::text("$passCount passes", null) . ", ". SS_Cli::text("$failCount fails", null) . ", and 0 exceptions\n";
33  
-		
  39
+
  40
+		echo sprintf("\n\n%d tests run: %s, %s, and %s\n", $testCount, SS_Cli::text("$passCount passes"), SS_Cli::text("$failCount failures"), SS_Cli::text("$incompleteCount incomplete"));
  41
+
34 42
 		if(function_exists('memory_get_peak_usage')) {
35 43
 			echo "Maximum memory usage: " . number_format(memory_get_peak_usage()/(1024*1024), 1) . "M\n\n";
36 44
 		}
@@ -72,7 +80,6 @@ public function endTest( PHPUnit_Framework_Test $test, $time) {
72 80
 	
73 81
 	protected function writeTest($test) {
74 82
 		if ($test['status'] != 1) {
75  
-			
76 83
 			$filteredTrace = array();
77 84
 			$ignoredClasses = array('TestRunner');
78 85
 			foreach($test['trace'] as $item) {
@@ -88,11 +95,15 @@ protected function writeTest($test) {
88 95
 					&& $item['function'] == 'run') break;
89 96
 				
90 97
 			}
91  
-			
92  
-			echo "\n\n" . SS_Cli::text($this->testNameToPhrase($test['name']) . "\n". $test['message'] . "\n", 'red', null, true);
93  
-			echo SS_Backtrace::get_rendered_backtrace($filteredTrace, true);
  98
+
  99
+			if( $test['status'] == 2) {
  100
+				echo "\n" . SS_Cli::text($this->testNameToPhrase($test['name']) . "\n" . $test['message'] . "\n", 'yellow', null, true);
  101
+			} else {
  102
+				echo "\n" . SS_Cli::text($this->testNameToPhrase($test['name']) . "\n". $test['message'] . "\n", 'red', null, true);
  103
+				echo SS_Backtrace::get_rendered_backtrace($filteredTrace, true);
  104
+			}
94 105
 			echo "\n--------------------\n";
95 106
 		}
96 107
 	}
97 108
 	
98  
-}
  109
+}
14  dev/SapphireTestReporter.php
@@ -274,16 +274,24 @@ private function getTestException(PHPUnit_Framework_Test $test, Exception $e) {
274 274
 	/**
275 275
 	 * Display error bar if it exists
276 276
 	 */
277  
-	public function writeResults() {		
  277
+	public function writeResults() {
278 278
 		$passCount = 0;
279 279
 		$failCount = 0;
280 280
 		$testCount = 0;
  281
+		$incompleteCount = 0;
281 282
 		$errorCount = 0;
282 283
 		
283 284
 		foreach($this->suiteResults['suites'] as $suite) {
284 285
 			foreach($suite['tests'] as $test) {
285 286
 				$testCount++;
286  
-				($test['status'] == 1) ? $passCount++ : $failCount++;
  287
+				if($test['status'] == 2) {
  288
+					$incompleteCount++;
  289
+				} elseif($test['status'] == 1) {
  290
+					$passCount++;
  291
+				} else {
  292
+					$failCount++;
  293
+				}
  294
+
287 295
 				if ($test['status'] != 1) {
288 296
 					echo "<div class=\"failure\"><span>&otimes; ". $this->testNameToPhrase($test['name']) ."</span><br>";
289 297
 					echo "<pre>".htmlentities($test['message'], ENT_COMPAT, 'UTF-8')."</pre><br>";
@@ -294,7 +302,7 @@ public function writeResults() {
294 302
 		}
295 303
 		$result = ($failCount > 0) ? 'fail' : 'pass';
296 304
 		echo "<div class=\"status $result\">";
297  
-		echo "<h2><span>$testCount</span> tests run: <span>$passCount</span> passes, <span>$failCount</span> fails, and <span>0</span> exceptions</h2>";
  305
+		echo "<h2><span>$testCount</span> tests run: <span>$passCount</span> passes, <span>$failCount</span> failures, and <span>$incompleteCount</span> incomplete</h2>";
298 306
 		echo "</div>";
299 307
 		
300 308
 	}

0 notes on commit fc18b2c

Please sign in to comment.
Something went wrong with that request. Please try again.