-
-
Notifications
You must be signed in to change notification settings - Fork 106
fix: add regression test for TestContext.Current null issue during property injection #3995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…roperty injection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds a regression test for issue #3991, where TestContext.Current was null during property injection, and implements the fix by setting TestContext.Current before processing property data sources in the test registration phase.
Key Changes:
- Added
TestContext.Current = testContextinRegisterTestArgumentsAsyncto ensure the context is available during property data source resolution - Added comprehensive regression test that captures and validates
TestContext.Currentavailability during property injection
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| TUnit.Engine/Services/TestArgumentRegistrationService.cs | Sets TestContext.Current at the start of RegisterTestArgumentsAsync to make it available during property injection and data source resolution |
| TUnit.UnitTests/PropertyDataSourceInjectionTests.cs | Adds regression test with custom data source attribute that accesses TestContext.Current during property injection to verify the fix |
| CapturedCancellationToken = testContext?.CancellationToken ?? default | ||
| }; | ||
| }; | ||
| await Task.CompletedTask; |
Copilot
AI
Dec 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The await Task.CompletedTask; statement is unreachable code after a yield return statement in an async iterator method. This line will never execute and should be removed. The method naturally completes after all yield return statements have been executed.
| await Task.CompletedTask; |
Fixes #3991