Using testify

Use testify's assert or require functions to write clear, concise assertions in your Go unit tests.

Use assert or require from github.com/stretchr/testify to write assertions in your tests. Import the package, then call assertion functions like assert.Equal or require.NoError with the test instance t as the first argument.

import "github.com/stretchr/testify/assert"

func TestExample(t *testing.T) {
    result := 2 + 2
    assert.Equal(t, 4, result)
}