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 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示