mage-erp/model [no test files] ok mage-erp/controller0.026s coverage:2.0% of statements ok mage-erp/handler0.021s coverage:3.1% of statements 可以看到输出了coverage百分比,我这个项目没啥测试代码,临时增加的。 4.覆盖率测试可视化分析 对刚才生成的coverage.out 进行可视化分析: go tool cover -html=co...
go tool cover -func=coverage.out 2.2、如果不想直接输出,而是写到文件: go tool cover -func=coverage.out -o coverage.data 3、如何查看具体代码行的覆盖情况 2.1 通过浏览器 html 文件查看 # 下面生成的html可以再浏览器打开,查看具体代码行的覆盖 go tool cover -html=coverage.out -o coverage.html2.2...
go tool cover -html=./coverage/coverage.cov -o /data/reports/coverage.html ./coverage/gocover-cobertura < coverage.cov > /data/reports/coverage.xml 生成xml报告时需要安装一个小插件:go get github.com/t-yuki/gocover-cobertura 将bin下的gocover-cobertura放到方便执行的目录下即可使用 4 将测试报告...
go test -coverprofile=coverage.out 这将执行所有的测试用例并生成一个名为`coverage.out`的覆盖率文件。 #步骤3:生成覆盖率报告 使用`go tool cover`命令处理覆盖率文件并生成覆盖率报告。运行以下命令: go tool cover -html=coverage.out -o coverage.html 这将生成一个名为`coverage.html`的HTML文件,其中包...
ok mage-erp/handler0.021s coverage:3.1%of statements 1. 2. 3. 4. 可以看到输出了coverage百分比,我这个项目没啥测试代码,临时增加的。 4.覆盖率测试可视化分析 对刚才生成的coverage.out 进行可视化分析: go tool cover -html=coverage.out 可以看到打开了一个网页: ...
go test -coverprofile=coverage.out b. 对文件进行分析 go tool cover -func=coverage.out c. 生成html分析页面 没有被测试用例代码覆盖会标记为红色. go tool cover -html=coverage.out -o coverage.html 3. 命令列表 Usage of'go tool cover':Given a coverage profile produced by'go test':生成覆盖率...
2,use goc build to build the target service,and run the generated binary.✗ goc build.✗./simple-go-server 第三步就是查询我们的代码覆盖率结果 代码语言:javascript 复制 3,use goc profile togetthe code coverage profileofthe started simple server above ✗ goc profile...
4.运行测试,最后使用kill -USR1 $PID停止服务,以收集覆盖率数据,目录中会生成coverage.cov覆盖率信息文件 5.转化.cov文件 直接在窗口中展示覆盖率报告: go tool cover -func=coverage.cov 生成html报告文件 go tool cover -html coverage.cov -o coverage.html ...
– 执行:GoCoverage,创建一个测试覆盖结果文件,并打开浏览器展示当前包的情况。 – 执行:GoErrCheck,检查当前包种可能的未捕获的errors。 – 执行:GoFiles,显示当前包对应的源文件列表。 – 执行:GoDeps,显示当前包的依赖包列表。 – 执行:GoImplements,显示当前类型实现的interface列表。
coverage: 85.7% of statements ok baseCodeExample/gotest 0.005s 从覆盖率来看(coverage: 85.7% of statements),单元测试没有覆盖全部的代码,只有 85.7% ,我们可以通过如下命令将 cover 的详细信息保存到cover.out 中。 go test -cover -coverprofile=cover.out -covermode=count ...