]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Provide more information when unit tests fail with exceptions
authorepriestley <git@epriestley.com>
Thu, 17 Nov 2011 19:12:17 +0000 (11:12 -0800)
committerepriestley <git@epriestley.com>
Thu, 17 Nov 2011 19:29:48 +0000 (11:29 -0800)
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

index 59cc7bc661cc78975b280b54d4bed683e80cd24e..2b8b8c2736dcebcc60bc87725b36472eca67b047 100644 (file)
@@ -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);
         }
       }
     }