package facade
import testing
var expect = A module runing\nB module runing
// TestFAcadeAPI...
func TestFacadeAPI(t *testing.T) {
api := NewAPI()
ret := api.Test()
t.Logf(testing log)
if ret != expect {
t.Fatalf(expect %s, return %s, expect, ret)
}
}
go test -v
## 显示输出内容 t.Logf("testing log")
命令
go test ... [参数]
参数说明
- bench regexp 执行相应的 benchmarks,例如 -bench=.;
- cover 开启测试覆盖率;
- run regexp 只运行 regexp 匹配的函数,例如 -run=Array 那么就执行包含有 Array 开头的函数;
- v 显示测试的详细命令
Example
执行全部单元测试 go test ./...
单独执行某个文件测试用例 go test helloworld_test.go
单独执行某个文件某个方法 go test -v -run TestA select_test.go
运行指定目录及所有子目录下的测试用例 go test foo/...
运行指定前缀的测试用例 go test foo...
运行GOPATH下的所有测试用例 go test ...