使用 gomock 寫測試

gomock 原本是 golang 官方維護的套件,不過因為有一段時間沒有在維護了,在 2023 年 6 月時就改由 uber 團隊接手維護了。 停止維護: https://github.com/golang/mock 目前有在維護: https://github.com/uber-go/mock 安裝工具 安裝 mockgen 工具...

31 December 2023 · 2 min · nyo

如何寫 Go 的效能測試(Benchmark)

go 的測試工具 go test 有 benchmark 工具可以使用。 不用自己寫工具就可以很輕鬆的測試程式碼效能。 開始寫 benchmark 測試 建立 _test.go 結尾的檔案 function 要以 Benchmark 開頭 使用 b *testing.B 參數 將要測試的...

15 July 2023 · 2 min · nyo

Go Test All Testing in Project

想要跑當前專案下的所有 test 1 $ go test ./... Reference How to go test all testings in my project? - Stack Overflow

12 October 2017 · 1 min · nyo