go test
默認執(zhí)行當前目錄下以xxx_test.go
的測試文件。
go test -v
可以看到詳細的輸出信息祝旷。
go test -v xxx_test.go
指定測試單個文件巷懈,但是該文件中如果調(diào)用了其它文件中的模塊會報錯椅贱。
指定某個測試函數(shù)運行:
go test -v -test.run Testxxx
注意: 該測試會測試包含該函數(shù)名的所有函數(shù),即如果待測試的函數(shù)名是TestSyncResourceQuota
窿祥,那么指令go test -v -test.run TestSyncResourceQuota
會測試包含該函數(shù)名的所有函數(shù)(比如下面的TestSyncResourceQuotaSpecChange株憾、TestSyncResourceQuotaSpecHardChange
等函數(shù)),詳細如下:
root@fstgb014:~/go-work/src/k8s.io/kubernetes/pkg/controller/resourcequota# go test -v -test.run TestSyncResourceQuota
=== RUN TestSyncResourceQuota
--- PASS: TestSyncResourceQuota (0.00s)
=== RUN TestSyncResourceQuotaSpecChange
--- PASS: TestSyncResourceQuotaSpecChange (0.00s)
=== RUN TestSyncResourceQuotaSpecHardChange
--- PASS: TestSyncResourceQuotaSpecHardChange (0.00s)
=== RUN TestSyncResourceQuotaNoChange
--- PASS: TestSyncResourceQuotaNoChange (0.00s)
PASS
ok k8s.io/kubernetes/pkg/controller/resourcequota 0.148s