From a8b42312445b6e8f58afab8686e5464d8823263c Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 17 Nov 2011 11:12:17 -0800 Subject: [PATCH] Provide more information when unit tests fail with exceptions Summary: When a unit test throws an exception, provide more data (type, trace) in the test failure message. Previously, we would show only the message itself, which may not be very useful in debugging test failures. Test Plan: Ran "arc unit" on a test which throws, got a stack trace. Reviewers: edward, btrahan, jungejason, nh, tuomaspelkonen, aran Reviewed By: nh CC: aran, nh Differential Revision: 1123 --- src/unit/engine/phutil/testcase/ArcanistPhutilTestCase.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/unit/engine/phutil/testcase/ArcanistPhutilTestCase.php b/src/unit/engine/phutil/testcase/ArcanistPhutilTestCase.php index 59cc7bc6..2b8b8c27 100644 --- a/src/unit/engine/phutil/testcase/ArcanistPhutilTestCase.php +++ b/src/unit/engine/phutil/testcase/ArcanistPhutilTestCase.php @@ -231,7 +231,11 @@ abstract class ArcanistPhutilTestCase { } catch (ArcanistPhutilTestTerminatedException $ex) { // Continue with the next test. } catch (Exception $ex) { - $this->failTest($ex->getMessage()); + $ex_class = get_class($ex); + $ex_message = $ex->getMessage(); + $ex_trace = $ex->getTraceAsString(); + $message = "EXCEPTION ({$ex_class}): {$ex_message}\n{$ex_trace}"; + $this->failTest($message); } } }