From 03bc3c281e5cb5adbaba44b195c6ecec09618b0f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 3 Dec 2008 19:09:16 +0000 Subject: Make sure that we always run teardown, even when the test throws an exception --- modules/unit_test/libraries/Unit_Test.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'modules/unit_test') 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 -- cgit v1.2.3