Skip to content

Add extra test assertions around tests#13536

Merged
Youssef1313 merged 2 commits into
mainfrom
dev/ygerges/extra-assertion
Apr 14, 2026
Merged

Add extra test assertions around tests#13536
Youssef1313 merged 2 commits into
mainfrom
dev/ygerges/extra-assertion

Conversation

@Youssef1313

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 14, 2026 07:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_runningTests assertions around PreInvoke, PostInvoke, and the test-case Run lifecycle.
  • Capture and assert stability of selected Microsoft.Build.Framework.Traits values across each test case run (excluded for OM tests).
  • Define IS_OM_TESTS in 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.

Comment thread src/Shared/UnitTests/TestAssemblyInfo.cs
Comment thread src/Shared/UnitTests/TestAssemblyInfo.cs
@Youssef1313

Copy link
Copy Markdown
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.

@Youssef1313 Youssef1313 enabled auto-merge (squash) April 14, 2026 12:00
@Youssef1313 Youssef1313 merged commit 12afa00 into main Apr 14, 2026
10 checks passed
@Youssef1313 Youssef1313 deleted the dev/ygerges/extra-assertion branch April 14, 2026 19:09
This was referenced Jun 10, 2026
This was referenced Jun 11, 2026
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.

3 participants