Go言語のCoverageツール

カバレッジの取得

go test ./url -coverprofile cover.out

カバレッジの可視化

go tool cover -html=cover.out

カバレッジのレポート出力

カバレッジの確認

go tool cover -func=cover.out
github.com/ishisaka/go_by_example/url/url.go:20:        Parse           100.0%
github.com/ishisaka/go_by_example/url/url.go:40:        String          100.0%
github.com/ishisaka/go_by_example/url/url.go:72:        SetScheme       100.0%
total:                                                  (statements)    100.0%

カバレッジのレポート出力

go tool cover -o cover.html -html=cover.out

参考情報