-
Notifications
You must be signed in to change notification settings - Fork 731
Improve failure message for string assertions when checking for equality #2972
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
Merged
dennisdoomen
merged 2 commits into
fluentassertions:support-7.0
from
vbreuss:backport-2307
Jan 17, 2025
Merged
Improve failure message for string assertions when checking for equality #2972
dennisdoomen
merged 2 commits into
fluentassertions:support-7.0
from
vbreuss:backport-2307
Jan 17, 2025
Conversation
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
(cherry picked from commit bb50da5)
…ity (fluentassertions#2307) * Draft improved failure message when checking for equality. * Use line and column for multiline strings * Fix failing tests * Fix Qodana issues * Fix further failing tests * Also fix tests on MacOS (due to different newline) * Calculate expected index * Fix paranthesis * Move specific methods from common StringExtensions to the `StringEqualityStrategy` class * Fix review comments from @dennisdoomen and add tests for word boundary algorithm * Improve tests by using [raw string literals](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/strings/#raw-string-literals) * Update releases.md * Implement review comments from @jnyrup * Adapt due to survived mutants * Adapt test names --------- Co-authored-by: Valentin Breuß <v.breuss@tig.at> (cherry picked from commit 6859575)
Pull Request Test Coverage Report for Build 12824421774Details
💛 - Coveralls |
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
|
jnyrup
reviewed
Jan 17, 2025
ScarletKuro
referenced
this pull request
in AwesomeAssertions/AwesomeAssertions
Jan 18, 2025
… for equality" (#2972) * Refactor `StringValidator` to avoid inheritance (#2296) (cherry picked from commit bb50da5) * Improve failure message for string assertions when checking for equality (#2307) * Draft improved failure message when checking for equality. * Use line and column for multiline strings * Fix failing tests * Fix Qodana issues * Fix further failing tests * Also fix tests on MacOS (due to different newline) * Calculate expected index * Fix paranthesis * Move specific methods from common StringExtensions to the `StringEqualityStrategy` class * Fix review comments from @dennisdoomen and add tests for word boundary algorithm * Improve tests by using [raw string literals](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/strings/#raw-string-literals) * Update releases.md * Implement review comments from @jnyrup * Adapt due to survived mutants * Adapt test names --------- Co-authored-by: Valentin Breuß <v.breuss@tig.at> (cherry picked from commit 6859575)
This was referenced Jul 21, 2025
This was referenced Jan 1, 2026
This was referenced Jan 8, 2026
This was referenced Jan 15, 2026
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.
Backport #2307 to v7:
When asserting that two strings are equal, and one of the strings is longer than 8 characters or contains a NewLine, instead of simply stating at which index the first difference occurs, this difference is made visible using arrows, e.g.
throws with message
For multi-line strings, instead of only providing information about the index, the failure message also contains the line and column information, e.g.
…but they differ on line 5 and column 1 (index 93):For short single-line strings the behaviour remains unchanged!
Let's see, how open you are for community commits on v7, or if we should consider it dead...