项目仓库: https://github.com/stretchr/testify
debian 软件包: golang-github-stretchr-testify-dev
简单使用:
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSomething(t *testing.T) {
var a string = "Hello"
var b string = "Hello"
assert.Equal(t, a, b, "The two words should be the same.")
}
stretchr/assert 包断言不会立即失败,而是返回一个 bool 值,如果想要立即失败,需要使用 stretchr/require 包。