mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT TestReporter now reports incomplete tests properly
This commit is contained in:
parent
0e31846937
commit
fc18b2c788
@ -14,12 +14,19 @@ class CliTestReporter extends SapphireTestReporter {
|
||||
$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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,7 +36,8 @@ class CliTestReporter extends SapphireTestReporter {
|
||||
} 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";
|
||||
@ -72,7 +80,6 @@ class CliTestReporter extends SapphireTestReporter {
|
||||
|
||||
protected function writeTest($test) {
|
||||
if ($test['status'] != 1) {
|
||||
|
||||
$filteredTrace = array();
|
||||
$ignoredClasses = array('TestRunner');
|
||||
foreach($test['trace'] as $item) {
|
||||
@ -89,8 +96,12 @@ class CliTestReporter extends SapphireTestReporter {
|
||||
|
||||
}
|
||||
|
||||
echo "\n\n" . SS_Cli::text($this->testNameToPhrase($test['name']) . "\n". $test['message'] . "\n", 'red', null, 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";
|
||||
}
|
||||
}
|
||||
|
@ -278,12 +278,20 @@ class SapphireTestReporter implements PHPUnit_Framework_TestListener {
|
||||
$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>⊗ ". $this->testNameToPhrase($test['name']) ."</span><br>";
|
||||
echo "<pre>".htmlentities($test['message'], ENT_COMPAT, 'UTF-8')."</pre><br>";
|
||||
@ -294,7 +302,7 @@ class SapphireTestReporter implements PHPUnit_Framework_TestListener {
|
||||
}
|
||||
$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>";
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user