mercredi 26 décembre 2018

Why is a helper object passed around when testing in golang?

I need to test a function

func Sum(a, b int) {
    return a + b
}

func TestSum(t *testing.T) {
    assert.Equal(t, 5, Sum(2,3))
}

Why do I have to provide t as a helper object to assert.Equal()? Couldn't it be implicitly inferred like other languages? (Example Ruby's rspec)

I couldn't find a reference doc/blog/video explaining this, hence asking it here. If someone would be kind to point me to it.

Thanks.

Aucun commentaire:

Enregistrer un commentaire