> 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.That obviously depends on the implementation details but since we talk about testify the API is: assert.Equal(t, want, got, format, [args...]). On Mon, 5 Oct 2020 at 18:45, Ian Lance Taylor <[email protected]> wrote: > On Mon, Oct 5, 2020 at 8:47 AM Viktor Kojouharov <[email protected]> > 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 a topic in the > Google Groups "golang-nuts" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/golang-nuts/ZoJ5isoeea4/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXNV6bLQQUFmVn14xnxheALTKbv1_oQODovboLEziPKSw%40mail.gmail.com > . > -- Vladimir Varankin [email protected] -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAGLqCMmj7NB3Sem0BDdyJBj-cxGXVmBY-6StRXAP6MvwZUyOnQ%40mail.gmail.com.
