Open bombela opened 8 years ago
In assert.Equal(t, a, b) if a and b do not have the same type, the test will fail, but the output will be the same as a value equality test failure.
assert.Equal(t, a, b)
a
b
It is confusing, because on complex equality assertion, ones might not realize the problem is different type, not unequal values.
Consider this example:
type struct Foo { V int } type Foos []Foo
assert.Equal(t, Foos{{1}, {2}}, Foos{{1}, {2})
compared to:
assert.Equal(t, Foos{{1}, {2}}, []Foo{{1}, {2})
The second case will fail with a "not equal" message.
Instead, assert.Equal and similar should output an explicit message about type inequality.
assert.Equal
cc @abhinav @prashantv @breerly
There's a PR open about improving error messages: #327
Could likely be closed since https://github.com/stretchr/testify/pull/327 was merged.
In
assert.Equal(t, a, b)
ifa
andb
do not have the same type, the test will fail, but the output will be the same as a value equality test failure.It is confusing, because on complex equality assertion, ones might not realize the problem is different type, not unequal values.
Consider this example:
compared to:
The second case will fail with a "not equal" message.
Instead,
assert.Equal
and similar should output an explicit message about type inequality.cc @abhinav @prashantv @breerly