One minute
1.10以降のGoのMultiPackageテスト
以前は複数のパッケージのカバレッジを取るのにこんなことをやっていた。
#!/bin/bash
set -e
echo "" > coverage.txt
go test -i ./...
for d in $(go list ./...); do
go test -race -coverprofile=profile.out -covermode=atomic $d
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done
1.10以降はこれでいけるようになった。
go test -race -coverprofile=coverage.txt -covermode=atomic ./...
楽チン!
Read other posts