Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestReport now reports incomplete tests properly #320

Merged
merged 1 commit into from
Apr 14, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions dev/CliTestReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,19 @@ public function writeResults() {
$passCount = 0;
$failCount = 0;
$testCount = 0;
$incompleteCount = 0;
$errorCount = 0;

foreach($this->suiteResults['suites'] as $suite) {
foreach($suite['tests'] as $test) {
$testCount++;
($test['status'] == 1) ? $passCount++ : $failCount++;
if($test['status'] == 2) {
$incompleteCount++;
} elseif($test['status'] === 1) {
$passCount++;
} else {
$failCount++;
}
}
}

Expand All @@ -29,8 +36,9 @@ public function writeResults() {
} else {
echo SS_Cli::text(" AT LEAST ONE FAILURE ", "white", "red");
}
echo "\n\n$testCount tests run: " . SS_Cli::text("$passCount passes", null) . ", ". SS_Cli::text("$failCount fails", null) . ", and 0 exceptions\n";


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"));

if(function_exists('memory_get_peak_usage')) {
echo "Maximum memory usage: " . number_format(memory_get_peak_usage()/(1024*1024), 1) . "M\n\n";
}
Expand Down Expand Up @@ -72,7 +80,6 @@ public function endTest( PHPUnit_Framework_Test $test, $time) {

protected function writeTest($test) {
if ($test['status'] != 1) {

$filteredTrace = array();
$ignoredClasses = array('TestRunner');
foreach($test['trace'] as $item) {
Expand All @@ -88,11 +95,15 @@ protected function writeTest($test) {
&& $item['function'] == 'run') break;

}

echo "\n\n" . SS_Cli::text($this->testNameToPhrase($test['name']) . "\n". $test['message'] . "\n", 'red', null, true);
echo SS_Backtrace::get_rendered_backtrace($filteredTrace, true);

if( $test['status'] == 2) {
echo "\n" . SS_Cli::text($this->testNameToPhrase($test['name']) . "\n" . $test['message'] . "\n", 'yellow', null, true);
} else {
echo "\n" . SS_Cli::text($this->testNameToPhrase($test['name']) . "\n". $test['message'] . "\n", 'red', null, true);
echo SS_Backtrace::get_rendered_backtrace($filteredTrace, true);
}
echo "\n--------------------\n";
}
}

}
}
14 changes: 11 additions & 3 deletions dev/SapphireTestReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,24 @@ private function getTestException(PHPUnit_Framework_Test $test, Exception $e) {
/**
* Display error bar if it exists
*/
public function writeResults() {
public function writeResults() {
$passCount = 0;
$failCount = 0;
$testCount = 0;
$incompleteCount = 0;
$errorCount = 0;

foreach($this->suiteResults['suites'] as $suite) {
foreach($suite['tests'] as $test) {
$testCount++;
($test['status'] == 1) ? $passCount++ : $failCount++;
if($test['status'] == 2) {
$incompleteCount++;
} elseif($test['status'] == 1) {
$passCount++;
} else {
$failCount++;
}

if ($test['status'] != 1) {
echo "<div class=\"failure\"><span>&otimes; ". $this->testNameToPhrase($test['name']) ."</span><br>";
echo "<pre>".htmlentities($test['message'], ENT_COMPAT, 'UTF-8')."</pre><br>";
Expand All @@ -294,7 +302,7 @@ public function writeResults() {
}
$result = ($failCount > 0) ? 'fail' : 'pass';
echo "<div class=\"status $result\">";
echo "<h2><span>$testCount</span> tests run: <span>$passCount</span> passes, <span>$failCount</span> fails, and <span>0</span> exceptions</h2>";
echo "<h2><span>$testCount</span> tests run: <span>$passCount</span> passes, <span>$failCount</span> failures, and <span>$incompleteCount</span> incomplete</h2>";
echo "</div>";

}
Expand Down