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 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应