-
Notifications
You must be signed in to change notification settings - Fork 50
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
Improved error message when checks with variables fail #92
Comments
That would be great, but I'm not sure it's possible. I think it will be necessary to keep |
Another option is something like this: assert.Check(t, a == 2, "a=%s", a)
// parser_test.go:20: assertion failed: expression is false: a == 2: a=1 If printing the args as part of the "extra messages" is a common pattern it could be done with a convenience function: assert.Check(t, x > y, assert.Args(x, y))
// parser_test.go:20: assertion failed: expression is false: x > y: x=2, y=100 I don't know if we can do any better than that. |
Would func TestAreYouTheSame(t *testing.T) {
a := 1
assert.Equal(t, a, 2)
} Produces:
|
Or, if you need func TestAreYouTheSame(t *testing.T) {
a := 1
assert.Check(t, cmp.Equal(a, 2))
assert.Equal(t, a, 2)
}
|
I realise this would be difficult (or potentially impossible) to solve, but when an expression fails it would be very useful to have the value available.
eg.
The following test code:
Produces the error:
This is not that helpful, as I now need to edit the code to print the actual value.
Ideally it would print something like:
The text was updated successfully, but these errors were encountered: