Skip to content

Conversation

@thomhurst
Copy link
Owner

Fixes #3991

Copilot AI review requested due to automatic review settings December 6, 2025 10:14
@thomhurst thomhurst enabled auto-merge (squash) December 6, 2025 10:14
Copy link

Copilot AI left a 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 = testContext in RegisterTestArgumentsAsync to ensure the context is available during property data source resolution
  • Added comprehensive regression test that captures and validates TestContext.Current availability 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;
Copy link

Copilot AI Dec 6, 2025

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.

Suggested change
await Task.CompletedTask;

Copilot uses AI. Check for mistakes.
@thomhurst thomhurst disabled auto-merge December 6, 2025 10:39
@thomhurst thomhurst merged commit 64e794e into main Dec 6, 2025
17 of 19 checks passed
@thomhurst thomhurst deleted the bug/3991 branch December 6, 2025 10:39
@claude claude bot mentioned this pull request Dec 6, 2025
1 task
This was referenced Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TestContext.Current is null when injecting properties in 1.4.0

1 participant