-
Notifications
You must be signed in to change notification settings - Fork 731
Improve rendering of exception messages when using WithMessage #3039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve rendering of exception messages when using WithMessage #3039
Conversation
Qodana for .NETIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked Contact Qodana teamContact us at qodana-support@jetbrains.com
|
a06ba55 to
9a6ee29
Compare
187131b to
e02714b
Compare
Pull Request Test Coverage Report for Build 14133594137Details
💛 - Coveralls |
There was a problem hiding this comment.
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 improves the rendering of exception messages by reformatting multi-line messages and refactoring string comparison and validation methods. Key changes include updating tests to assert multi‐line formatting, renaming and consolidating validation methods across multiple string comparison strategies, and adjusting the trimming behavior in the formatting component.
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Tests/FluentAssertions.Specs/Exceptions/OuterExceptionSpecs.cs | Added tests to verify multi‐line, long, and short exception message rendering. |
| Src/FluentAssertions/Specialized/ExceptionAssertions.cs | Refactored exception message assertion logic for clearer output. |
| Src/FluentAssertions/Primitives/StringWildcardMatchingStrategy.cs | Renamed methods and updated formatting for multi‐line messages. |
| Src/FluentAssertions/Primitives/StringValidatorSupportingNull.cs | Updated to call the new AssertForEquality method. |
| Src/FluentAssertions/Primitives/StringValidator.cs | Replaced null validation with a call to AssertNeitherIsNull for better consistency. |
| Src/FluentAssertions/Primitives/StringStartStrategy.cs | Renamed mismatch validation method and added null checks. |
| Src/FluentAssertions/Primitives/StringEqualityStrategy.cs | Renamed methods and updated error message formatting. |
| Src/FluentAssertions/Primitives/StringEndStrategy.cs | Modified error messages and integrated a new null check method. |
| Src/FluentAssertions/Primitives/StringContainsStrategy.cs | Renamed methods and updated error message parameter ordering. |
| Src/FluentAssertions/Primitives/IStringComparisonStrategy.cs | Updated the interface to match the new method names. |
| Src/FluentAssertions/Formatting/Line.cs | Adjusted trimming behavior in ToString to explicitly remove trailing spaces. |
Files not reviewed (1)
- Tests/FluentAssertions.Specs/FluentAssertions.Specs.csproj: Language not supported
Comments suppressed due to low confidence (1)
Src/FluentAssertions/Primitives/StringContainsStrategy.cs:25
- [nitpick] Verify that the parameter order in the error message is intentional; currently, 'subject' is passed as the first parameter and 'expected' as the second, which might lead to confusion compared to similar strategies.
$"Expected {context:string} {0} to contain the equivalent of {1} {expectedOccurrence}{reason}, but found it {actual.Times()}."
Src/FluentAssertions/Primitives/StringWildcardMatchingStrategy.cs
Outdated
Show resolved
Hide resolved
e02714b to
14ae9cc
Compare
|
@jnyrup did you not approve or reject the PR on purpose? |
In a test like
When_one_of_the_types_does_not_match_the_generic_type_it_should_throw_with_a_clear_explanation, a multi-line exception message like thisafter this PR, they will be rendered as