Apply structured assertion messages (RFC 012) to Assert.Fail / Assert.Inconclusive#8296
Open
Evangelink wants to merge 1 commit into
Open
Apply structured assertion messages (RFC 012) to Assert.Fail / Assert.Inconclusive#8296Evangelink wants to merge 1 commit into
Evangelink wants to merge 1 commit into
Conversation
….Inconclusive Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates MSTest Assert.Fail and Assert.Inconclusive message formatting to align with RFC 012 structured assertion messages, updating localized resources and adjusting unit/integration test expectations accordingly.
Changes:
Assert.Failnow throws viaStructuredAssertionMessage(empty summary) producingAssertion failed.+ optional user message on the next line.Assert.Inconclusivenow formats asAssert.Inconclusive.(optionally followed by the user message) using a newFrameworkMessages.InconclusivePrefixresource.- Updated unit tests, adapter platform-services tests, and an acceptance test expectation to match the new message formats.
Show a summary per file
| File | Description |
|---|---|
| test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.ScopeTests.cs | Updates scope behavior test expectation for the new Assert.Fail message layout. |
| test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.InconclusiveTests.cs | Updates inconclusive regression test substring expectation to the new prefix. |
| test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.FailInconclusive.cs | Adds new focused unit tests covering Fail/Inconclusive message formatting scenarios. |
| test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Execution/TestMethodInfoTests.cs | Updates adapter unit test expected exception messages for new Fail/Inconclusive formats. |
| test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Execution/TestExecutionManagerTests.cs | Updates expected failure output message for Assert.Fail. |
| test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Execution/TestClassInfoTests.cs | Updates expected initialization/cleanup failure messages for new formats. |
| test/UnitTests/MSTestAdapter.PlatformServices.UnitTests/Execution/TestAssemblyInfoTests.cs | Updates expected initialization/cleanup failure messages for new formats. |
| test/IntegrationTests/MSTest.Acceptance.IntegrationTests/RetryTests.cs | Updates acceptance test output expectation to match the new multi-line Assert.Fail message. |
| src/TestFramework/TestFramework/Resources/FrameworkMessages.resx | Adds InconclusivePrefix resource entry. |
| src/TestFramework/TestFramework/Resources/xlf/FrameworkMessages.*.xlf | Regenerates localized XLF entries to include InconclusivePrefix. |
| src/TestFramework/TestFramework/Assertions/Assert.Inconclusive.cs | Implements new Assert.Inconclusive formatting using InconclusivePrefix. |
| src/TestFramework/TestFramework/Assertions/Assert.Fail.cs | Switches Assert.Fail to StructuredAssertionMessage-based formatting. |
Copilot's findings
- Files reviewed: 24/24 changed files
- Comments generated: 2
|
|
||
| testHostResult.AssertOutputContains("failed TestMethod5"); | ||
| testHostResult.AssertOutputContains("Assert.Fail failed. Failing TestMethod4. Attempts: 4 (from TestContext: 4)"); | ||
| testHostResult.AssertOutputContains("Assertion failed.\r\nFailing TestMethod4. Attempts: 4 (from TestContext: 4)"); |
Comment on lines
+48
to
+55
|
|
||
| // See https://github.com/dotnet/sdk/issues/25373 | ||
| public void InconclusiveDoesNotThrowWhenMessageContainsInvalidStringFormatCompositeAndNoArgumentsPassed_Regression() | ||
| { | ||
| Action action = () => Assert.Inconclusive("{"); | ||
| action.Should().Throw<AssertInconclusiveException>() | ||
| .WithMessage("Assert.Inconclusive. {"); | ||
| } |
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.
Continues the rollout of RFC 012 — Structured Assertion Messages by migrating
Assert.FailandAssert.Inconclusiveto the new formats. Follows the patterns used by the prior assertion migrations (#8170, #8187, #8210, #8214, #8258, #8260, #8265).Output format
Assert.Fail("Order processing should not reach this branch")Before:
After:
Assert.Inconclusive("Database server not available for integration tests.")Before:
After:
Notes
Assert.Failnow usesStructuredAssertionMessagewith an empty summary, so the message is justAssertion failed.plus the optional user message on the next line.Assert.Inconclusivenow formats messages asAssert.Inconclusive. <message>(or justAssert.Inconclusive.), intentionally droppingfailedper RFC 012. This is the documented breaking change toAssertInconclusiveException.Messageand it still does not use the universalAssertion failed.prefix.InconclusivePrefixresource and regenerated the corresponding XLF files viaUpdateXlf.Validation
.\build.cmd -c Debug -projects src\TestFramework\TestFramework\TestFramework.csproj— passed..\.dotnet\dotnet.exe msbuild src\TestFramework\TestFramework\TestFramework.csproj /t:UpdateXlf /p:Configuration=Debug— passed..\.dotnet\dotnet.exe test test\UnitTests\TestFramework.UnitTests\TestFramework.UnitTests.csproj -c Debug --no-build— 3935/3935 passed..\.dotnet\dotnet.exe build test\UnitTests\MSTestAdapter.PlatformServices.UnitTests\MSTestAdapter.PlatformServices.UnitTests.csproj -c Debug— passed.artifacts\bin\MSTestAdapter.PlatformServices.UnitTests\Debug\<tfm>\MSTestAdapter.PlatformServices.UnitTests.exe(net462, net48, net8.0, net8.0-windows10.0.18362.0, net9.0) — 3954/3954 passed.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com