Make sure that we always run teardown, even when the test throws an exception

This commit is contained in:
Bharat Mediratta
2008-12-03 19:09:16 +00:00
parent 1e647c2a03
commit 03bc3c281e

View File

@@ -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