生成profile
go test -coverprofile=coverage.pro
使用go工具链生成html文件
go tool cover -html=./coverage.pro -o coverage.html
在浏览器下打开html文件
go tool cover XML (Cobertura) export
gocover-cobertura < coverage.pro> coverage.xml
可以在gitlab 显示覆盖率
go get code.google.com/p/go.tools/cmd/cover
但是得到错误
package code.google.com/p/go.tools/cmd/cover: unrecognized import path
正确的路径是:
go get golang.org/x/tools/cmd/cover
https://www.cnblogs.com/shining5/p/8572107.html
https://www.elastic.co/cn/blog/code-coverage-for-your-golang-system-tests
https://www.cnblogs.com/zhaoxd07/p/8028847.html
https://github.com/t-yuki/gocover-cobertura
ttps://brantou.github.io/2017/05/24/go-cover-story/
https://learnku.com/docs/go-blog/cover/6552
cover
go test -coverprofile=coverage.out
go tool cover -html=coverage.out
gitlab
go get -u code.google.com/p/go.tools/cmd/cover x
go get github.com/t-yuki/gocover-cobertura √
go get golang.org/x/tools/cmd/cover √
go test -coverprofile=coverage.txt -covermode go help testflag
go test -coverprofile fmtcoverage.html fmt
gocover-cobertura coverage.xml git add coverage.xml