Go Coverage Report 与 Jenkins 的集成

我想知道是否有任何工具可以转换go test -coverprofile=cover.out成詹金斯可以接受的格式?我找到了一些工具,比如go-junit-reportgo2xunit,但它们实际上只是转换输出go test -v,而不是覆盖率报告。

我想直接了解 Jenkins 中的详细测试覆盖率。基本上,我想查看 Jenkins 网页中的go tool cover -func=cover.out输出go tool cover -html=cover.out


元芳怎么了
浏览 436回答 3
3回答

至尊宝的传说

有几个 go 工具可以将覆盖数据从go testJenkins 转换为 Cobertura:gocover-cobertura或gocov和gocov-xml。您可以gocover-cobertura按如下方式使用:$ go get github.com/t-yuki/gocover-cobertura$ go test -coverprofile=cover.out example.com/demo/...ok&nbsp; &nbsp; &nbsp; example.com/demo&nbsp; &nbsp; 0.008s&nbsp; coverage: 0.0% of statementsok&nbsp; &nbsp; &nbsp; example.com/demo/cmd/demo&nbsp; &nbsp;0.020s&nbsp; coverage: 23.4% of statements$ gocover-cobertura < cover.out > coverage.xml$ head coverage.xml<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd"><coverage line-rate="0.35415787" branch-rate="0" version="" timestamp="1520609235359" lines-covered="839" lines-valid="2369" branches-covered="0" branches-valid="0" complexity="0">&nbsp; &nbsp; &nbsp; &nbsp; <sources>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <source>/usr/local/go/src</source>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <source>/Users/wilfred/workspace/go-scratch/src</source>&nbsp; &nbsp; &nbsp; &nbsp; </sources>&nbsp; &nbsp; &nbsp; &nbsp; <packages>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <package name="example.com/demo/cmd/demo" line-rate="0.4848485" branch-rate="0" complexity="0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <classes>请注意,您需要 Go 1.10+ 才能在一次运行-coverprofile中针对多个包运行。

繁华开满天机

https://github.com/AlekSi/gocov-xml这就是我们需要的。使用 Coberuta 插件生成覆盖配置文件。

慕桂英3389331

Go 覆盖率报告没有专门的插件,通用代码覆盖率也没有。对于这样的报告,我使用HTML Publisher Plugin来发布.html在构建过程中创建的文件。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go