将Go测试输出转换为XUnit

rob*_*rit 6 xunit go jenkins

如何以XUnit格式输出Go的测试库输出以与Jenkins集成?没有命令行选项可以输出到XML或XUnit格式go test.

rob*_*rit 9

有一个很好的小插件转换:https://github.com/tebeka/go2xunit

要安装它:

go get github.com/tebeka/go2xunit
Run Code Online (Sandbox Code Playgroud)

要使用它:

# Run your tests like normal, but pipe the verbose output to the converter
go test -v | $GOPATH/bin/go2xunit > test_output.xml
Run Code Online (Sandbox Code Playgroud)

如果你有$GOPATH/bin正常的$PATH:

go test -v | go2xunit > test_output.xml
Run Code Online (Sandbox Code Playgroud)

  • `github.com/tebeka/go2xunit` 现已存档。有更新的吗? (2认同)
  • @SachithMuhandiram https://github.com/jstemmer/go-junit-report (2认同)