On Mon, Oct 5, 2020 at 10:31 AM Vladimir Varankin <vladi...@varank.in>
wrote:

> > 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...]).
>

The testify assert/require code may be a little backwards and verbose when
compared to a naked t.Error(), however, it provides a lot of helper
functions for comparing types and values which results in much clearer,
shorter tests in the end. You can assert.EqualValues() to ignore type, for
example, or do deep compares without having to code that yourself. I'd say
it's wonderful.



>
> On Mon, 5 Oct 2020 at 18:45, Ian Lance Taylor <i...@golang.org> wrote:
>
>> 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 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
>> 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
>> .
>>
>
>
> --
> Vladimir Varankin
> vladi...@varank.in
>
> --
> 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/CAGLqCMmj7NB3Sem0BDdyJBj-cxGXVmBY-6StRXAP6MvwZUyOnQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/golang-nuts/CAGLqCMmj7NB3Sem0BDdyJBj-cxGXVmBY-6StRXAP6MvwZUyOnQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CA%2Bv29Lt3KPhuTV_u2xExqW2B2spagP-vNzVFY7%3DKP8KTr33mPw%40mail.gmail.com.

Reply via email to