-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Diffs no longer call string() #1108
Comments
I got bitten by this as well. :-( |
Given that the assertions never call such methods I think we should not be showing their output in diffs. There is a risk of saying "these two things are different and here is a diff showing that they are identical". @mitar can you give a more detailed experience report explaining how this bit you? |
It is simple, if errors contain private fields, diffing them does not return anything useful. While |
Yea ok, that's a common theme. Private struct fields are used in comparisons with For most custom errror types I've seen in the wild their While we decide whether to expose the configuration, you can put the method output into assert.Equalf(t, expected, actual, "\nexpected: %q\nactual: %q", expected.Error(), actual.Error()) |
But the difference is between having
Yes, but this is really tedious and it works only at top-level, but not if error is nested somewhere in a struct (not common, but still). Maybe a solution could be to check for a custom interface method defined by this package and used only when diffing which expects to dump the whole struct into string? |
https://github.com/stretchr/testify/blob/master/assert/assertions.go#L1654
Not sure why this was added by default. Can we make this configurable or remove it?
The text was updated successfully, but these errors were encountered: