-
-
Couldn't load subscription status.
- Fork 94
Fix skipped tests executing constructors by using placeholder instance #2723
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
Co-authored-by: thomhurst <[email protected]>
Co-authored-by: thomhurst <[email protected]>
|
@copilot retry |
Co-authored-by: thomhurst <[email protected]>
I've continued working on the fix and made significant progress. The issue where skipped tests still executed constructors has been resolved using a Key changes in commit 27439b6:
Verification: The fix now successfully prevents constructor execution for skipped tests while maintaining existing functionality for non-skipped tests. |
Fixes issue where test constructors were being called even for tests marked with
[Skip]attribute, which could cause unwanted side effects or performance issues.Problem
Test instances were created unconditionally during the test building phase in
TestBuilder.CreateInstance(), regardless of whether the test had a[Skip]attribute. The skip check only happened later during test execution inSingleTestExecutor, meaning constructors ran unnecessarily for skipped tests.Solution
TestBuilderto check for basicSkipAttributeinstances during test discoverySkippedTestInstanceas a type-safe placeholder to avoid null reference issues while preventing constructor executionSingleTestExecutorto handle pre-skipped testsKey Changes
TUnit.Core/SkippedTestInstance.cs- New singleton placeholder classTUnit.Engine/Building/TestBuilder.cs- Early skip detection logicTesting
Verified that:
[Skip]attributed testsFixes #2562
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.