Fix a few cases for how exceptions are passed to AfterX hooks#5240
Merged
Conversation
c0ad7ce to
d7c0de2
Compare
d7c0de2 to
41598d6
Compare
Member
Author
|
I've added these linked issues to the 4.6 milestone. There's just a few additional test cases I'll need to cover and then this will be ready for review |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts how exceptions are surfaced to execution “AfterX” hooks so that hooks receive the underlying exception (not wrapper exceptions) and do not treat Assert.Pass()’s SuccessException as an error.
Changes:
- Normalize exceptions passed into After* execution hooks by unwrapping wrapper exceptions and filtering out
SuccessException. - Add test fixtures and assertions covering exception propagation for AfterTest, AfterEverySetUp/TearDown, and test-action hooks.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| src/NUnitFramework/framework/Internal/ExecutionHooks/ExecutionHooks.cs | Unwraps exceptions and suppresses SuccessException before passing to After* hook handlers. |
| src/NUnitFramework/testdata/ExecutionHooks/CombinedHookTestFixtures.cs | Adds new hook-enabled fixtures/attributes used by tests to capture exceptions from hooks. |
| src/NUnitFramework/tests/ExecutionHooks/ExceptionHandling/TestThrowsExceptionHooksProceedsToExecuteTests.cs | Adds new unit tests asserting correct exception values (and absence) in After* hooks. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… failure Agent-Logs-Url: https://github.com/nunit/nunit/sessions/cf703463-aadb-4e1b-9dfc-e810ffaba573 Co-authored-by: stevenaw <439844+stevenaw@users.noreply.github.com>
Member
Author
|
This is now ready for review |
Closed
Member
Author
|
Thanks @OsirisTerje |
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.
Fixes #5237 (
Assert.Pass()shouldnt populateExceptionproperty)Fixes #5238 (Unwrap the exception before populating the hook data property)