covGo - go覆盖率平台

python
linux、mac
yuzg667 · August 05, 2022 · 5585 次阅读 · 0 条评论


covGo

GO 覆盖率平台

  • 支持增量覆盖率、全量覆盖率
  • 实时收集覆盖率、无需写单测
  • 支持按照规定时间段收集
  • 支持多版本形式的覆盖率收集
  • 支持集群多服务收集

环境要求

系统:linux、mac(不支持 windows)

Go: 1.13+

python: 3.6+

安装

coGo 服务端安装- 全手工自助方式

(若动手能力差,请移步docker 安装版)

1、安装 GOC

# Mac/AMD64
curl -s -L "https://github.com/qiniu/goc/releases/latest" | sed -nE 's!.*"([^"]*-darwin-amd64.tar.gz)".*!https://github.com\1!p' | xargs -n 1 curl -L  | tar -zx && chmod +x goc && mv goc /usr/local/bin

# Linux/AMD64
curl -s -L "https://github.com/qiniu/goc/releases/latest" | sed -nE 's!.*"([^"]*-linux-amd64.tar.gz)".*!https://github.com\1!p' | xargs -n 1 curl -L  | tar -zx && chmod +x goc && mv goc /usr/local/bin

# Linux/386
curl -s -L "https://github.com/qiniu/goc/releases/latest" | sed -nE 's!.*"([^"]*-linux-386.tar.gz)".*!https://github.com\1!p' | xargs -n 1 curl -L  | tar -zx && chmod +x goc && mv goc /usr/local/bin

安装后命令行输入 goc,查看是否有效。

2、安装 gocov、gocov-xml、gocov-html

go install github.com/axw/gocov/gocov@latest
go install github.com/AlekSi/gocov-xml@latest
go install github.com/matm/gocov-html@latest

安装后命令行输入 gocov、gocov-xml、gocov-html 查看是否有效。

被测服务器安装

只需要安装 goc,安装方法同上

运行

covGo 所在服务器开启

假设 covGo 所在服务器 ip 为 10.200.8.210

1、covGo 服务

1.1、安装依赖:pip install -r requirements.txt

1.2、修改 settings.py 中的数据库配置,执行 init.sql 初始化数据库

1.3、命令行运行:python3 manage.py runserver 0.0.0.0:8000

2、 开启 goc 服务

命令行运行goc server ,默认端口为 7777

被测服务器(一般指 go 后端服务器)开启

进入 go 项目的根目录,使用 goc 编译打包:

goc build --center=http://10.200.8.210:7777 --agentport=:46599

备注:--center=的值为 goc 服务 ip 端口; --agentport=的值为被测服务外露的端口

使用

covGo 平台页面

1、新建项目 输入图片说明

2、新建覆盖率任务 输入图片说明

3、等待覆盖率任务,进入页面查看结果 输入图片说明 输入图片说明 输入图片说明

本项目代码仓库地址

github: https://github.com/yuzg667/covGo

gitee: https://gitee.com/yuzg667/covGo

goc: goc is a comprehensive coverage testing system for The Go Programming Language, especially for some complex scenarios, like system testing code coverage collection and accurate testing.

gocov: Coverage reporting tool for The Go Programming Language

gocov-html: A simple helper tool for generating HTML output from gocov.

gocov-xml: A simple helper tool for generating XML output in Cobertura format for CIs like Jenkins and others from gocov.




评论列表
No Comment at the moment.