Skip to content

Commit 9eb51ff

Browse files
LukeTowerssebastianbergmann
authored andcommitted
Fix: preserve tearDown() exceptions when test is skipped
Currently, if a test calls markTestSkipped() (throwing a SkippedWithMessageException) and tearDown() then throws its own exception (e.g. due to uninitialized state), PHPUnit swallows the tearDown() exception and only reports the skip and any resulting risky‑test warnings. This change treats SkippedWithMessageException differently so that exceptions raised in tearDown() are still surfaced, making it easier to diagnose teardown issues even in skipped tests.
1 parent 5431254 commit 9eb51ff

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Framework/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ final public function runBare(): void
620620
Event\Code\ComparisonFailureBuilder::from($e),
621621
);
622622
} catch (Throwable $exceptionRaisedDuringTearDown) {
623-
if (!isset($e)) {
623+
if (!isset($e) || $e instanceof SkippedWithMessageException) {
624624
$this->status = TestStatus::error($exceptionRaisedDuringTearDown->getMessage());
625625
$e = $exceptionRaisedDuringTearDown;
626626

0 commit comments

Comments
 (0)