Skip to content

Apply structured assertion messages (RFC 012) to Assert.Fail / Assert.Inconclusive#8296

Open
Evangelink wants to merge 1 commit into
mainfrom
dev/amauryleve/assert-fail-inconclusive-rfc012
Open

Apply structured assertion messages (RFC 012) to Assert.Fail / Assert.Inconclusive#8296
Evangelink wants to merge 1 commit into
mainfrom
dev/amauryleve/assert-fail-inconclusive-rfc012

Conversation

@Evangelink
Copy link
Copy Markdown
Member

Continues the rollout of RFC 012 — Structured Assertion Messages by migrating Assert.Fail and Assert.Inconclusive to 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:

Assert.Fail failed. Order processing should not reach this branch

After:

Assertion failed.
Order processing should not reach this branch

Assert.Inconclusive("Database server not available for integration tests.")

Before:

Assert.Inconclusive failed. Database server not available for integration tests.

After:

Assert.Inconclusive. Database server not available for integration tests.

Notes

  • Assert.Fail now uses StructuredAssertionMessage with an empty summary, so the message is just Assertion failed. plus the optional user message on the next line.
  • Assert.Inconclusive now formats messages as Assert.Inconclusive. <message> (or just Assert.Inconclusive.), intentionally dropping failed per RFC 012. This is the documented breaking change to AssertInconclusiveException.Message and it still does not use the universal Assertion failed. prefix.
  • Added the new InconclusivePrefix resource and regenerated the corresponding XLF files via UpdateXlf.
  • Updated affected unit and integration test expectations that asserted on the legacy single-line formats.

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

….Inconclusive

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 16, 2026 16:40
Copy link
Copy Markdown
Contributor

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

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.Fail now throws via StructuredAssertionMessage (empty summary) producing Assertion failed. + optional user message on the next line.
  • Assert.Inconclusive now formats as Assert.Inconclusive. (optionally followed by the user message) using a new FrameworkMessages.InconclusivePrefix resource.
  • 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. {");
}
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