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 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 Ubuntu20.04无法连接GitHub
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥30 C++行情软件的tick数据如何高效的合成K线