From 300dfa9d070ec9286b875cf5d2619b53f9d8d7de Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Wed, 13 Aug 2008 03:42:45 +0000 Subject: [PATCH] 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 --- dev/CliTestReporter.php | 2 ++ dev/SapphireTestReporter.php | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dev/CliTestReporter.php b/dev/CliTestReporter.php index 27d6a4474..679b89c25 100644 --- a/dev/CliTestReporter.php +++ b/dev/CliTestReporter.php @@ -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"; } } diff --git a/dev/SapphireTestReporter.php b/dev/SapphireTestReporter.php index b53263d8a..c758325eb 100644 --- a/dev/SapphireTestReporter.php +++ b/dev/SapphireTestReporter.php @@ -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 "
⊗ ". $this->testNameToPhrase($test['name']) ."
"; echo "
".htmlentities($test['message'])."

"; - echo "In line {$test['exception']['line']} of {$test['exception']['file']}
"; + echo Debug::get_rendered_backtrace($test['trace']); + echo ""; } } }