項目倉庫: https://github.com/stretchr/testifygit
debian 軟件包: golang-github-stretchr-testify-devgithub
簡單使用:golang
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 包。ui