我正在使用latest Go GAE SDK开发服务器。每次更改后我都会运行测试:
goapp test -test.v=true
我正在使用-cover
来记录goapp help testflag
所描述的覆盖范围:
goapp test -cover -test.v=true -test.coverprofile=c.out
[..]
coverage: 53.8% of statements
ok _/var/lib/jenkins/jobs/loyalty/workspace 30.464s
这成功完成并打印测试所涵盖的行的百分比。但是,尝试可视化结果:
goapp tool cover -html=c.out
cover: can't find "app.go": cannot find package "_/home/ingo/git/loyalty/" in any of:
/home/ingo/Downloads/go_appengine_sdk_linux_amd64-1.9.10/go_appengine/goroot/src/pkg/_/home/ingo/git/loyalty (from $GOROOT)
/home/ingo/git/loyalty/src/_/home/ingo/git/loyalty (from $GOPATH)
Go的封面工具是否仅适用于非GAE应用?我是否必须以不同方式打包我的应用程序以显示覆盖率结果?
我之前没有成功问过on golang-nuts。
答案 0 :(得分:5)
有open issue与之相关。作为临时解决方法,我正在收集和可视化覆盖结果之间运行。
goapp test -cover -test.v=true -test.coverprofile=c.out
sed -i -e "s#.*/\(.*\.go\)#\./\\1#" c.out
goapp tool cover -html c.out -o coverage.html