Repository navigation
Improve equality assertion failure message - #241
Conversation
8ad0fcb to
3fc5b97
Compare
| loc: SourceLocation): Expectations = { | ||
| comparisonA.diff(expected, found) match { | ||
| case Comparison.Result.Success => Expectations(Validated.validNel(())) | ||
| case Comparison.Result.Failure(report) => |
There was a problem hiding this comment.
One problem with printing - expected and + found is that we assume the Comparison instance will respect the ANSI escape codes and + / - signs in the diff.
I think we can follow this up with some guidance on defining a Comparison.
There was a problem hiding this comment.
I don't think the users should have to to worry about it : the comparison report should let untouched by Weaver's selection of colouring in its headers.
If somebody implementing the comparison decides to put some Ansi in their report, Weaver should respect that.
There was a problem hiding this comment.
We won't modify their colouring. However if we add the following header text:
val expectedHeader = AnsiColors.c("- expected", AnsiColors.LightRed)
val obtainedHeader = AnsiColors.c("+ found", AnsiColors.LightGreen)So if a user decides to use - for found, or different colours, the header will be misleading.
There was a problem hiding this comment.
I see. In that case, it's possible that the right course of action is to add this header in the output of the OOTB Comparison Weaver provides
There was a problem hiding this comment.
We could incorporate (+ expected, - found) into the OOTB Comparion, and leave the expect.same / expect.eql text here.
19c816f to
60898c8
Compare
The
expect.sameandexpect.eqlmethods haveexpectedas their first parameter andobtainedas their second.expectedandobtainedare printed in the diff report in the failure message, but it's not obvious which parameter is which. To complicate things further, we usefoundas the parameter name in code, butobtainedas the name in the failure message.This PR improves the failure message to print
in expect.same(expected, found). This should help users correlate the diff report to their code.Before
After