You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the reason that assert.* functions receive first expected value and then actual?
For instance: assert.Equal(t, 5, count) instead of assert.Equal(t, count, 5)
We can compare this example with if condition.
It's more natural to read if count == 5 than if 5 == count.
Another point to accept an actual param first is that it's easier to spot which fields get checked in a test because usually actual param is a variable but expected is a constant. For instance:
asssert.Equal(t, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor", title)
asssert.Equal(t, "Ut enim ad minim veniam, quis nostrud exercitation ullamco", description)
vs
asssert.Equal(t, title, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor")
asssert.Equal(t, description, "Ut enim ad minim veniam, quis nostrud exercitation ullamco")
The text was updated successfully, but these errors were encountered:
It's rather a question than an issue.
What is the reason that
assert.*
functions receive first expected value and then actual?For instance:
assert.Equal(t, 5, count)
instead ofassert.Equal(t, count, 5)
We can compare this example with
if
condition.It's more natural to read
if count == 5
thanif 5 == count
.Another point to accept an actual param first is that it's easier to spot which fields get checked in a test because usually actual param is a variable but expected is a constant. For instance:
vs
The text was updated successfully, but these errors were encountered: