亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Go Coverage Report 與 Jenkins 的集成

Go Coverage Report 與 Jenkins 的集成

Go
元芳怎么了 2022-01-17 16:50:27
我想知道是否有任何工具可以轉換go test -coverprofile=cover.out成詹金斯可以接受的格式?我找到了一些工具,比如go-junit-report和go2xunit,但它們實際上只是轉換輸出go test -v,而不是覆蓋率報告。我想直接了解 Jenkins 中的詳細測試覆蓋率?;旧?,我想查看 Jenkins 網頁中的go tool cover -func=cover.out輸出go tool cover -html=cover.out。
查看完整描述

3 回答

?
至尊寶的傳說

TA貢獻1789條經驗 獲得超10個贊

有幾個 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      example.com/demo    0.008s  coverage: 0.0% of statements

ok      example.com/demo/cmd/demo   0.020s  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">

        <sources>

                <source>/usr/local/go/src</source>

                <source>/Users/wilfred/workspace/go-scratch/src</source>

        </sources>

        <packages>

                <package name="example.com/demo/cmd/demo" line-rate="0.4848485" branch-rate="0" complexity="0">

                        <classes>

請注意,您需要 Go 1.10+ 才能在一次運行-coverprofile中針對多個包運行。


查看完整回答
反對 回復 2022-01-17
?
繁華開滿天機

TA貢獻1816條經驗 獲得超4個贊

https://github.com/AlekSi/gocov-xml

這就是我們需要的。使用 Coberuta 插件生成覆蓋配置文件。


查看完整回答
反對 回復 2022-01-17
?
慕桂英3389331

TA貢獻2036條經驗 獲得超8個贊

Go 覆蓋率報告沒有專門的插件,通用代碼覆蓋率也沒有。

對于這樣的報告,我使用HTML Publisher Plugin來發布.html在構建過程中創建的文件。


查看完整回答
反對 回復 2022-01-17
  • 3 回答
  • 0 關注
  • 398 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號