douguizhuang8276 2014-09-01 11:30
浏览 683
已采纳

golang-codecoverage始终显示覆盖率:语句的0.0%

I created one sample go project and created a unit test cases for the same (In Linux environment, go1.3 version)

When i ran go test the output would be

PASS
ok supported_db 0.201s

And i tried to perform code coverage for whole application by using go test -cover command it shows

go tool: no such tool "cover"; to install:
go get code.google.com/p/go.tools/cmd/cover

Also i checked the coverage while running a specific test case by running go test -cover CouchDB_test.go command it shows

ok command-line-arguments 0.158s coverage: 0.0% of statements

please help me to run code coverage in golang.

  • 写回答

2条回答 默认 最新

  • douyun3022 2014-09-01 11:34
    关注

    Try first:

    go test -coverprofile=coverage.out
    

    I then run, to see the result:

    go tool cover -html=coverage.out
    

    If the 1.3 version was installed through an upgrade of 1.1, 1.2, ..., you can try, as in issue 110:

    I solved this by completely removing $GOPATH/src/code.google.com/p/go.tools and install cover again:

    go get code.google.com/p/go.tools/cmd/cover
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺