Golang的Codeclimate测试覆盖率格式化程序 [英] Codeclimate test coverage formatter for Golang

查看:130
本文介绍了Golang的Codeclimate测试覆盖率格式化程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Codeclimate文档编写了如何指定coverage格式化程序.但是,当我尝试将覆盖范围发送给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

失败:

错误:找不到任何可行的格式化程序.可用的格式化程序:simplecov,lcov,coverage.py,三叶草,gocov,gcov,cobertura,jacoco

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

我已经安装了 gocov .我也用 goconv 生成了一份报告:

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

gocov test -coverprofile=out

然后我尝试通过多种方式将报告文件指定为Codeclimate:

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

但是没有运气...

我没有找到与 .codeclimate.yml 文件相关的与格式程序有关的指令.该文档以超级您知道"的风格编写,因此无济于事.如何使用Codeclimate启用/发送测试覆盖率?

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?

推荐答案

导出var:

CC_TEST_REPORTER_ID=...

运行:

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

这篇关于Golang的Codeclimate测试覆盖率格式化程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆