On Mon, Oct 5, 2020 at 8:47 AM Viktor Kojouharov <vkojouha...@gmail.com> wrote:
>
> I don't find any difference between calling t.Errorf and assert.Something 
> with a provided message. Both will populate the test log, with the later 
> giving you more details exactly where things differ from the expectation.

The difference is that since people write t.Error while writing the
test, it's very easy to provide all the relevant information, which in
many cases will involve more than just the values being compared.  A
common example would be a message like "MyFunction(%v) = %v, want %v".
When using an assert style function, the message will tend to lose the
value passed to MyFunction.  Or, it will be written as
assert.Equal(got, want, fmt.Sprintf("MyFunction(%v)", input)), but
that is harder to write, and therefore less likely to be written.
(It's also less efficient in the common case, though for a test that
is unlikely to matter.)

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXNV6bLQQUFmVn14xnxheALTKbv1_oQODovboLEziPKSw%40mail.gmail.com.

Reply via email to