Add extra test assertions around tests#13536
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens test-run invariants in the shared xUnit test framework wrapper to detect leakage of global MSBuild test state across test execution, with an opt-out for OM unit tests.
Changes:
- Add
BuildEnvironmentState.s_runningTestsassertions aroundPreInvoke,PostInvoke, and the test-caseRunlifecycle. - Capture and assert stability of selected
Microsoft.Build.Framework.Traitsvalues across each test case run (excluded for OM tests). - Define
IS_OM_TESTSin the OM unit test project to compile out the Traits assertions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Shared/UnitTests/TestAssemblyInfo.cs | Adds invariant assertions around xUnit invocation and test execution; introduces #if !IS_OM_TESTS guard for Traits stability checks. |
| src/Build.OM.UnitTests/Microsoft.Build.Engine.OM.UnitTests.csproj | Defines IS_OM_TESTS compilation constant to exclude the Traits assertions for OM tests. |
Member
Author
|
@rainersigwald @JanProvaznik This only makes assertions stronger, and simplifies a test I recently modified with the xunit.v3 update and fixes the comment I added that seems to be partially wrong or outdated. |
rainersigwald
approved these changes
Apr 14, 2026
This was referenced Apr 15, 2026
This was referenced Jun 10, 2026
This was referenced Jun 11, 2026
Merged
Open
Open
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.
No description provided.