From adb2fb51dfdd7aa641efc445dc0aa9ddbabc2b11 Mon Sep 17 00:00:00 2001 From: Tom Harper Date: Mon, 8 Apr 2024 10:03:55 +0100 Subject: [PATCH] Always call parent teardown even if an exception is thrown --- src/Concerns/Testable.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Concerns/Testable.php b/src/Concerns/Testable.php index 4075caf4..4c0250d3 100644 --- a/src/Concerns/Testable.php +++ b/src/Concerns/Testable.php @@ -234,11 +234,13 @@ trait Testable $afterEach = ChainableClosure::bound($this->__afterEach, $afterEach); } - $this->__callClosure($afterEach, func_get_args()); + try { + $this->__callClosure($afterEach, func_get_args()); + } finally { + parent::tearDown(); - parent::tearDown(); - - TestSuite::getInstance()->test = null; + TestSuite::getInstance()->test = null; + } } /**