diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-12-03 19:09:16 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-12-03 19:09:16 +0000 |
commit | 03bc3c281e5cb5adbaba44b195c6ecec09618b0f (patch) | |
tree | c8b64319665ed67cfc2bbe77f006d8cc293c6963 /modules/unit_test | |
parent | 1e647c2a03799c9f1bc890af9384994d4c9c7329 (diff) |
Make sure that we always run teardown, even when the test throws an exception
Diffstat (limited to 'modules/unit_test')
-rw-r--r-- | modules/unit_test/libraries/Unit_Test.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/unit_test/libraries/Unit_Test.php b/modules/unit_test/libraries/Unit_Test.php index 43fa2152..a03d725f 100644 --- a/modules/unit_test/libraries/Unit_Test.php +++ b/modules/unit_test/libraries/Unit_Test.php @@ -140,8 +140,12 @@ class Unit_Test_Core { $object->setup(); } - // Run the actual test - $object->$method_name(); + $e = null; + try { + + // Run the actual test + $object->$method_name(); + } catch (Exception $e) { } // Run teardown method if ($teardown === TRUE) @@ -149,6 +153,11 @@ class Unit_Test_Core { $object->teardown(); } + if ($e) { + throw $e; + } + + $this->stats[$class]['total']++; // Test passed |