fix: standardize assertion error message formatting#4933
Merged
Conversation
b2a1e5d to
b95aa12
Compare
Contributor
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. This is a clean, well-executed consistency pass. A few things worth noting positively:
No CLAUDE.md rule violations, no bugs, no logic issues, no security concerns. The change is purely mechanical string replacements with consistent application across all affected files. |
b95aa12 to
f1b432e
Compare
Standardize assertion error messages across TUnit.Assertions for consistency: - GetExpectation() now consistently uses "to [verb] [value]" pattern (e.g., "to match regex" instead of "text match regex") - Failure messages now consistently use "received [actual]" pattern instead of mixed "found", "value is", "was", "both values are" forms - Exception type names now consistently use .Name (short name) instead of .FullName (fully qualified name) Changes span 17 source files in TUnit.Assertions/Conditions and TUnit.Assertions/Collections, with corresponding updates to 10 test files.
f1b432e to
b4543a3
Compare
This was referenced Feb 22, 2026
Open
This was referenced Feb 23, 2026
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.
Summary
Fixes #4867
"to [verb] [value]"pattern across all assertion conditions (e.g.,"to match regex"instead of"text match regex","to not match pattern"instead of"text to not match with pattern")"received [actual]"instead of a mix of"found","value is","was","both values are", etc..Name(short name likeOtherException) instead of.FullName(fully qualified likeTUnit.Assertions.Tests.Assertions.Delegates.Throws+OtherException)Files changed
17 source files in
TUnit.Assertions/Conditions/andTUnit.Assertions/Collections/:StringAssertions.cs- regex/pattern match expectation wording, failure message standardizationStringEqualsAssertion.cs- "found" to "received" in diff messagesEqualsAssertion.cs,EquatableAssertion.cs-.FullNameto.Name, "found" to "received"NotEqualsAssertion.cs- "both values are" to "received"NullAssertion.cs- "value is null/default" to "received null/default"GreaterThanAssertion.cs,LessThanAssertion.cs,BetweenAssertion.cs- "value is null" / "found" to "received"PredicateAssertions.cs- "value does not satisfy" to "received"ReferenceEqualityAssertions.cs- "references are different/same" to "received different/same references"TypeOfAssertion.cs- "type was" to "received type"AsyncEnumerableAssertions.cs- "was null" / "item X was not found" to "received null" / "X was not found in the collection"CollectionCountSource.cs,CollectionChecks.cs- "found" to "received", "it was empty" to "received empty collection"SetAssertions.cs- "to equal" to "to be equal to" in GetExpectationThrowsAssertion.cs-.FullNameto.Name10 test files updated to match the new message format.
Test plan
dotnet build TUnit.Assertions/TUnit.Assertions.csprojpasses with 0 errorsdotnet test TUnit.Assertions.Tests/TUnit.Assertions.Tests.csproj- all 6935 tests pass across net8.0, net9.0, net10.0, and net48