Skip to content

Tighten scope-test assertions to full-string match#8226

Merged
Evangelink merged 4 commits into
mainfrom
dev/amauryleve/structured-messages-strings
May 14, 2026
Merged

Tighten scope-test assertions to full-string match#8226
Evangelink merged 4 commits into
mainfrom
dev/amauryleve/structured-messages-strings

Conversation

@Evangelink
Copy link
Copy Markdown
Member

Follow-up to RFC 012 (#7750, #8170, #8187).

Tightens the four Assert.AreEqual(1, 2) assertions in AssertTests.ScopeTests.cs from Should().Contain("Assert.AreEqual failed.") to Should().Be("Assert.AreEqual failed. Expected:<1>. Actual:<2>. 'expected' expression: '1', 'actual' expression: '2'.") for full-string match.

The scope tests already used full-string .Be(...) for the first inner exception; this brings the second inner exception (the AreEqual failure) to the same standard so the format is fully pinned down by the test.

No production-code changes. Build is clean (0 warnings, 0 errors).

Introduce the foundational types and helpers for structured multi-line
assertion failure messages as described in RFC 012:

- EvidenceLine: labeled line record struct for evidence blocks
- EvidenceBlock: collection of labeled lines with automatic alignment
- StructuredAssertionMessage: builder producing the new multi-line format
  (prefix + summary + user message + evidence block + call-site)
- AssertionValueRenderer: renders values per RFC 012 rules (null, quoted
  strings with escape sequences, booleans, collections as JSON arrays)
- AssertFailedException: add ExpectedText/ActualText public properties
- Assert: add ReportAssertFailed/ThrowAssertFailed overloads accepting
  StructuredAssertionMessage

No existing assertion methods are changed yet - this PR only introduces
the infrastructure that subsequent PRs will use to migrate each
assertion method to the new format.
# Conflicts:
#	src/TestFramework/TestFramework/Assertions/Assert.cs
#	src/TestFramework/TestFramework/Assertions/AssertionValueRenderer.cs
#	src/TestFramework/TestFramework/Assertions/EvidenceBlock.cs
#	src/TestFramework/TestFramework/Assertions/StructuredAssertionMessage.cs
#	test/UnitTests/TestFramework.UnitTests/Assertions/AssertFailedExceptionTests.cs
#	test/UnitTests/TestFramework.UnitTests/Assertions/AssertionValueRendererTests.cs
#	test/UnitTests/TestFramework.UnitTests/Assertions/EvidenceBlockTests.cs
#	test/UnitTests/TestFramework.UnitTests/Assertions/StructuredAssertionMessageTests.cs
Copilot AI review requested due to automatic review settings May 14, 2026 15:59
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

Note

Copilot was unable to run its full agentic suite in this review.

Tightens four test assertions in AssertTests.ScopeTests.cs from substring matches to full-string matches for the second inner exception's message, aligning them with the existing full-string assertions used for the first inner exception.

Changes:

  • Replaces Should().Contain("Assert.AreEqual failed.") with Should().Be(...) containing the complete expected message in four scope tests.
Show a summary per file
File Description
test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.ScopeTests.cs Tightens four assertions to full-string match for the AreEqual failure message.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

Copy link
Copy Markdown
Member Author

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

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

Generated by Expert Code Review (on open) for issue #8226 · ● 2.6M

@Evangelink
Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented May 14, 2026

@copilot resolve the merge conflicts in this pull request

Resolved in 0d9a41c by merging the latest main into this branch and reconciling the AssertTests.ScopeTests.cs conflicts so the newer first-inner-exception expectations from main are preserved while the second Assert.AreEqual checks remain full-string matches.

@Evangelink Evangelink merged commit d5757a8 into main May 14, 2026
4 of 10 checks passed
@Evangelink Evangelink deleted the dev/amauryleve/structured-messages-strings branch May 14, 2026 18:34
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