donglian2106 2017-08-19 20:34
浏览 99
已采纳

Golang的Codeclimate测试覆盖率格式化程序

Nowhere in Codeclimate docs written how to specify coverage formatter. But when I'm trying to send coverage to Codeclimate:

./cc-test-reporter before-build
./cc-test-reporter after-build

It is failing:

Error: could not find any viable formatter. available formatters: simplecov, lcov, coverage.py, clover, gocov, gcov, cobertura, jacoco

I have gocov installed. Also I generated a report with goconv:

gocov test -coverprofile=out

And I tried to specify the report file to Codeclimate in various ways:

./cc-test-reporter after-build out
./cc-test-reporter after-build < out

But had no luck...

I haven't found any formatter related directives for .codeclimate.yml file. The doc is written in super "you know" style so it didn't help. How to enable/send test coverage with Codeclimate?

  • 写回答

2条回答 默认 最新

  • douji1058 2017-08-19 21:35
    关注

    Export var:

    CC_TEST_REPORTER_ID=...
    

    Run:

    for pkg in $(go list ./... | grep -v vendor); do
        go test -coverprofile=$(echo $pkg | tr / -).cover $pkg
    done
    echo "mode: set" > c.out
    grep -h -v "^mode:" ./*.cover >> c.out
    rm -f *.cover
    
    ./cc-test-reporter after-build
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式