douya7121 2014-10-25 18:31
浏览 32
已采纳

如何在Go GAE应用程序上可视化代码覆盖率信息?

I am developing a server with the latest Go GAE SDK. I am running tests after every change:

goapp test -test.v=true

I am using -cover to record coverage as described by 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

This completes successfully and prints the percentage of lines covered by tests. However, attempting to visualize the results fails:

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)

Does Go's cover tool only work on non-GAE apps? Do I have to package my app differently in order to visualize the coverage results?

I unsuccessfully asked this on golang-nuts before.

  • 写回答

1条回答 默认 最新

  • douhuan1380 2014-10-28 14:20
    关注

    There is an open issue related to it. As a temporary workaround, I am running sed in between collecting and visualizing the coverage results.

    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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 R语言卸载之后无法重装,显示电脑存在下载某些较大二进制文件行为,怎么办
  • ¥15 java 的protected权限 ,问题在注释里