Include full traces in unit test failures, for easier debugging

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60605 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-08-13 03:42:45 +00:00
parent ec96a10a20
commit 300dfa9d07
2 changed files with 7 additions and 1 deletions

View File

@ -34,6 +34,8 @@ class CliTestReporter extends SapphireTestReporter {
if ($test['status'] != 1) {
echo $this->testNameToPhrase($test['name']) . "\n". $test['message'] . "\n";
echo "In line {$test['exception']['line']} of {$test['exception']['file']}" . "\n\n";
echo Debug::get_rendered_backtrace($test['trace'], true);
echo "\n--------------------\n";
}
}

View File

@ -152,6 +152,7 @@ class SapphireTestReporter implements PHPUnit_Framework_TestListener {
$this->currentTest['status'] = TEST_FAILURE;
$this->currentTest['message'] = $e->toString();
$this->currentTest['exception'] = $this->getTestException($test, $e);
$this->currentTest['trace'] = $e->getTrace();
}
/**
@ -168,6 +169,7 @@ class SapphireTestReporter implements PHPUnit_Framework_TestListener {
$this->currentTest['status'] = TEST_ERROR;
$this->currentTest['message'] = $e->getMessage();
$this->currentTest['exception'] = $this->getTestException($test, $e);
$this->currentTest['trace'] = $e->getTrace();
}
/**
@ -184,6 +186,7 @@ class SapphireTestReporter implements PHPUnit_Framework_TestListener {
$this->currentTest['status'] = TEST_INCOMPLETE;
$this->currentTest['message'] = $e->toString();
$this->currentTest['exception'] = $this->getTestException($test, $e);
$this->currentTest['trace'] = $e->getTrace();
}
/**
@ -266,7 +269,8 @@ class SapphireTestReporter implements PHPUnit_Framework_TestListener {
if ($test['status'] != 1) {
echo "<div class=\"failure\"><span>&otimes; ". $this->testNameToPhrase($test['name']) ."</span><br>";
echo "<pre>".htmlentities($test['message'])."</pre><br>";
echo "<code>In line {$test['exception']['line']} of {$test['exception']['file']}</code></div>";
echo Debug::get_rendered_backtrace($test['trace']);
echo "</div>";
}
}
}