1 回答

TA貢獻1801條經驗 獲得超16個贊
我認為gotestsum工具接近您正在尋找的東西。它是一個包裝器,用于打印格式化的測試輸出和測試運行的摘要。go test
違約:go test
go test ./...
? github.com/marco-m/timeit/cmd/sleepit [no test files]
ok github.com/marco-m/timeit/cmd/timeit 0.601s
違約:gotestsum
gotestsum
? cmd/sleepit
? cmd/timeit (cached)
DONE 11 tests in 0.273s <== see here
查看文檔和內置幫助,它寫得很好。
根據我的經驗,gotestsum(以及同一組織的其他工具)是好的。對我來說,能夠使用標準的Go測試包,沒有其他“測試框架”也非常重要。gotestsum允許我這樣做。
另一方面,為了真正滿足您的要求(打印聲明的測試數量并驗證該數量是否實際運行),您需要類似TAP的東西,即Test Anything協議,它適用于任何編程語言:
1..4 <== see here
ok 1 - Input file opened
not ok 2 - First line of the input valid
ok 3 - Read the rest of the file
not ok 4 - Summarized correctly # TODO Not written yet
TAP實際上非常好,很簡單。我記得有一個Go端口,tap-go,但現在被標記為存檔。
- 1 回答
- 0 關注
- 129 瀏覽
添加回答
舉報