環境 Ubuntu 14.04 Go 1.3.3 インストール $ go get code.google.com/p/go.tools/cmd/cover テストコードの用意 ソースコード package foo func Sum(a int, b int) int { return a + b } テストコード package foo import "testing" func TestSum(t *testing.T) { expected := 3 actual := Sum(1, 2) if actual != expected { t.Errorf("got %v\nwant %v", actual, expected) } } コンソール上で確認 $ go test -cover PASS coverage: 100.0% of statements ok _/Users/go
![Goでテストカバレッジ - Carpe Diem](https://cdn-ak-scissors.b.st-hatena.com/image/square/533c0bfa5135bb2ee4843cf9f48eb289d4311e66/height=288;version=1;width=512/http%3A%2F%2Fcdn-ak.f.st-hatena.com%2Fimages%2Ffotolife%2Fq%2Fquoll00%2F20141201%2F20141201210923.png)