2016-08-01 126 views
0

我在Jenkins中安裝了cobertura插件並使用以下命令#go test -cover -p 1 $PKGS | go-junit-report > report.xml運行了單元測試。我可以看到report.xml是使用代碼覆蓋率創建的,但我在Jenkins控制檯中看到下面的錯誤。您能否讓我們知道是什麼問題以及如何解決這個問題。使用cobertura插件轉到Jenkins的代碼覆蓋率報告

/bin/sh -xe /tmp/hudson1811800402022775798.sh 
[Cobertura] Publishing Cobertura coverage report... 
FATAL: Unable to find coverage results 
java.io.IOException: <workspace>/report.xml is not a cobertura coverage report, please check your report pattern 
    at hudson.plugins.cobertura.CoberturaPublisher$ParseReportCallable.invoke(CoberturaPublisher.java:566) 
    at hudson.plugins.cobertura.CoberturaPublisher$ParseReportCallable.invoke(CoberturaPublisher.java:536) 
    at hudson.FilePath.act(FilePath.java:1018) 
    at hudson.FilePath.act(FilePath.java:996) 
    at hudson.plugins.cobertura.CoberturaPublisher.perform(CoberturaPublisher.java:343) 
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20) 
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779) 
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720) 
    at hudson.model.Build$BuildExecution.post2(Build.java:185) 
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665) 
    at hudson.model.Run.execute(Run.java:1766) 
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43) 
    at hudson.model.ResourceController.execute(ResourceController.java:98) 
    at hudson.model.Executor.run(Executor.java:410) 
[Cobertura] No coverage results were found using the pattern '**/report.xml' relative to '<some directory>'. Did you enter a pattern relative to the correct directory? Did you generate the XML report(s) for Cobertura? 
Build step 'Publish Cobertura Coverage Report' changed build result to FAILURE 
Finished: FAILURE 

回答

0

我按照下面的步驟使用下面生成覆蓋率報表(去語言)

gocovxml

安裝gocov XML命令

$ go get github.com/axw/gocov/... 
$ go get github.com/AlekSi/gocov-xml 

執行去測試命令,如果您有多種包裝

gocov test $PKGS -p 1 | gocov-xml > report.xml 

提供report.xml將在發佈的Cobertura覆蓋報告(郵政建立詹金斯行動)

**/report.xml 
相關問題