go - 单元测试 unit test
访问量: 7
refer to: https://github.com/stretchr/testify/#installation
如何使用?
https://github.com/stretchr/testify/#installation
安装超级简单。
go get github.com/stretchr/testify
如何写?
package yours import ( "testing" "github.com/stretchr/testify/assert" ) func TestSomething(t *testing.T) { assert.True(t, true, "True is true!") // 第三个参数可以不用。 第二个参数为expected }
如何运行某个test ?
https://stackoverflow.com/questions/26092155/just-run-single-test-instead-of-the-whole-suite
go test -run TestMergeMultipleYearResult