Exceptions raised in after-test method are not reported for skipped tests#6281
Closed
LukeTowers wants to merge 1 commit intosebastianbergmann:11.5from
Closed
Exceptions raised in after-test method are not reported for skipped tests#6281LukeTowers wants to merge 1 commit intosebastianbergmann:11.5from
LukeTowers wants to merge 1 commit intosebastianbergmann:11.5from
Conversation
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.
This was referenced Jul 26, 2025
LukeTowers
added a commit
to wintercms/winter
that referenced
this pull request
Jul 26, 2025
Skipped tests still run their tearDown() method. Related: sebastianbergmann/phpunit#6281
bennothommo
pushed a commit
to wintercms/wn-system-module
that referenced
this pull request
Jul 26, 2025
Skipped tests still run their tearDown() method. Related: sebastianbergmann/phpunit#6281
bennothommo
pushed a commit
to wintercms/wn-backend-module
that referenced
this pull request
Jul 26, 2025
Skipped tests still run their tearDown() method. Related: sebastianbergmann/phpunit#6281
sebastianbergmann
added a commit
that referenced
this pull request
Aug 11, 2025
Owner
|
Cherry-picked into |
nicolas-grekas
added a commit
to symfony/symfony
that referenced
this pull request
Aug 12, 2025
This PR was merged into the 7.4 branch. Discussion ---------- run tests with PHPUnit 12.3 | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT The test updates reflect the following changes in PHPUnit 12.2 and 12.3: - a warning is emitted when a data provider provides data sets that have more values than the test method consuming the data set - the format in which data sets are displayed in test reports has changed affecting the modified test in the PhpUnitBridge (see sebastianbergmann/phpunit#6272) - errors triggered in the `tearDown()` method of skipped tests are no longer silence affecting the modified tests in the Form component where the `$defaultLocale` property is not initialised (see sebastianbergmann/phpunit#6281) Commits ------- cf7e41e run tests with PHPUnit 12.3
symfony-splitter
pushed a commit
to symfony/form
that referenced
this pull request
Aug 12, 2025
This PR was merged into the 7.4 branch. Discussion ---------- run tests with PHPUnit 12.3 | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT The test updates reflect the following changes in PHPUnit 12.2 and 12.3: - a warning is emitted when a data provider provides data sets that have more values than the test method consuming the data set - the format in which data sets are displayed in test reports has changed affecting the modified test in the PhpUnitBridge (see sebastianbergmann/phpunit#6272) - errors triggered in the `tearDown()` method of skipped tests are no longer silence affecting the modified tests in the Form component where the `$defaultLocale` property is not initialised (see sebastianbergmann/phpunit#6281) Commits ------- cf7e41e1092 run tests with PHPUnit 12.3
symfony-splitter
pushed a commit
to symfony/framework-bundle
that referenced
this pull request
Aug 12, 2025
This PR was merged into the 7.4 branch. Discussion ---------- run tests with PHPUnit 12.3 | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT The test updates reflect the following changes in PHPUnit 12.2 and 12.3: - a warning is emitted when a data provider provides data sets that have more values than the test method consuming the data set - the format in which data sets are displayed in test reports has changed affecting the modified test in the PhpUnitBridge (see sebastianbergmann/phpunit#6272) - errors triggered in the `tearDown()` method of skipped tests are no longer silence affecting the modified tests in the Form component where the `$defaultLocale` property is not initialised (see sebastianbergmann/phpunit#6281) Commits ------- cf7e41e1092 run tests with PHPUnit 12.3
symfony-splitter
pushed a commit
to symfony/yaml
that referenced
this pull request
Aug 12, 2025
This PR was merged into the 7.4 branch. Discussion ---------- run tests with PHPUnit 12.3 | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT The test updates reflect the following changes in PHPUnit 12.2 and 12.3: - a warning is emitted when a data provider provides data sets that have more values than the test method consuming the data set - the format in which data sets are displayed in test reports has changed affecting the modified test in the PhpUnitBridge (see sebastianbergmann/phpunit#6272) - errors triggered in the `tearDown()` method of skipped tests are no longer silence affecting the modified tests in the Form component where the `$defaultLocale` property is not initialised (see sebastianbergmann/phpunit#6281) Commits ------- cf7e41e1092 run tests with PHPUnit 12.3
symfony-splitter
pushed a commit
to symfony/security-bundle
that referenced
this pull request
Aug 12, 2025
This PR was merged into the 7.4 branch. Discussion ---------- run tests with PHPUnit 12.3 | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT The test updates reflect the following changes in PHPUnit 12.2 and 12.3: - a warning is emitted when a data provider provides data sets that have more values than the test method consuming the data set - the format in which data sets are displayed in test reports has changed affecting the modified test in the PhpUnitBridge (see sebastianbergmann/phpunit#6272) - errors triggered in the `tearDown()` method of skipped tests are no longer silence affecting the modified tests in the Form component where the `$defaultLocale` property is not initialised (see sebastianbergmann/phpunit#6281) Commits ------- cf7e41e1092 run tests with PHPUnit 12.3
symfony-splitter
pushed a commit
to symfony/console
that referenced
this pull request
Aug 12, 2025
This PR was merged into the 7.4 branch. Discussion ---------- run tests with PHPUnit 12.3 | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT The test updates reflect the following changes in PHPUnit 12.2 and 12.3: - a warning is emitted when a data provider provides data sets that have more values than the test method consuming the data set - the format in which data sets are displayed in test reports has changed affecting the modified test in the PhpUnitBridge (see sebastianbergmann/phpunit#6272) - errors triggered in the `tearDown()` method of skipped tests are no longer silence affecting the modified tests in the Form component where the `$defaultLocale` property is not initialised (see sebastianbergmann/phpunit#6281) Commits ------- cf7e41e1092 run tests with PHPUnit 12.3
symfony-splitter
pushed a commit
to symfony/validator
that referenced
this pull request
Aug 12, 2025
This PR was merged into the 7.4 branch. Discussion ---------- run tests with PHPUnit 12.3 | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT The test updates reflect the following changes in PHPUnit 12.2 and 12.3: - a warning is emitted when a data provider provides data sets that have more values than the test method consuming the data set - the format in which data sets are displayed in test reports has changed affecting the modified test in the PhpUnitBridge (see sebastianbergmann/phpunit#6272) - errors triggered in the `tearDown()` method of skipped tests are no longer silence affecting the modified tests in the Form component where the `$defaultLocale` property is not initialised (see sebastianbergmann/phpunit#6281) Commits ------- cf7e41e1092 run tests with PHPUnit 12.3
symfony-splitter
pushed a commit
to symfony/var-dumper
that referenced
this pull request
Aug 12, 2025
This PR was merged into the 7.4 branch. Discussion ---------- run tests with PHPUnit 12.3 | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT The test updates reflect the following changes in PHPUnit 12.2 and 12.3: - a warning is emitted when a data provider provides data sets that have more values than the test method consuming the data set - the format in which data sets are displayed in test reports has changed affecting the modified test in the PhpUnitBridge (see sebastianbergmann/phpunit#6272) - errors triggered in the `tearDown()` method of skipped tests are no longer silence affecting the modified tests in the Form component where the `$defaultLocale` property is not initialised (see sebastianbergmann/phpunit#6281) Commits ------- cf7e41e1092 run tests with PHPUnit 12.3
|
Yeah, I am getting OR for EVERY test if I update PHPUnit from 12.2.9 to 12.3.4. Also, with this, my teamcity pipeline timeouts and nothing can kill it besides a server restart :D Also I smell smoke brb (just kidding about this one!) |
Owner
|
|
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



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.
Related: laravel/framework#49502
Issue Fixed:
If a test is marked as skipped and your
tearDown()throws an exception before Laravel’s cleanup runs, PHPUnit will swallow that teardown exception and instead show the vague “Test code or tested code did not remove its own exception handlers” message.Why:
markTestSkipped()throws aSkippedWithMessageException.PHPUnit’s
runBare()always callstearDown()afterward, but iftearDown()throws, the exception is ignored because PHPUnit assumes the earlier skip exception is the “real” outcome.Since Laravel’s cleanup never ran, global handlers remain, triggering the risky-test warning.
Example:
Result:
Instead of the teardown exception, PHPUnit only reports: