`go test` CLI测试报告器的推荐

huangapple go评论98阅读模式
英文:

Recommendation for `go test` CLI test reporter

问题

我计划使用Go语言的testing包和go test来编写单元测试。我发现go test只能在命令行界面提供覆盖率报告,但我找不到任何go test选项可以让我获得测试套件的摘要报告。

例如,在运行测试之后,我希望看到一个简洁的测试报告,包括以下信息:

  • 测试套件中有多少个测试
  • 其中有多少个通过
  • 其中有多少个失败

我进行了一些网络搜索,但找不到任何好的Go语言原生选项/第三方工具/库来支持这一点。我只找到了一个库https://github.com/jstemmer/go-junit-report,它允许我将结果转换为JUnit XML,但这需要我进行进一步的处理才能得到摘要,不够方便。

我想知道在使用go testtesting包时,人们通常使用什么工具/库来生成这样的测试报告,特别是在通过命令行界面运行时。谢谢。

英文:

I plan to use the golang's testing package and go test for writing unit tests. I find go test only provides coverage report in the CLI, but I cannot find any go test option allowing me to get a summary report for the test suite.

For example, after running tests, I would like to see a minimal test report including the following information:

  • how many tests in the test suite
  • how many of them pass
  • how many of them fail

I did some web search, but cannot find any good golang native option/third party tool/library to support this. And I only found a library https://github.com/jstemmer/go-junit-report that allows me to convert the results into JUnit XML which requires me to do some further processing to get the summary, which is not convenient enough.

I would like to know when working with go test and the testing package, what is the tool/library people typically use for such test report generation purpose, in particular when running via CLI? Thanks.

答案1

得分: 3

这是 gotestsum,https://github.com/gotestyourself/gotestsum

在 GitHub 上的描述:
> go test 运行器,输出经过优化以便人类阅读,支持 JUnit XML 用于 CI 集成,并提供测试结果的摘要。

英文:

There is gotestsum, https://github.com/gotestyourself/gotestsum

Description at github:
> go test runner with output optimized for humans, JUnit XML for CI integration, and a summary of the test results.
"

答案2

得分: 1

go test命令有多种标志,其中包括-v详细标志。该选项会打印测试的详细信息以及测试套件的统计数据。

英文:

The go test command has a variety of flags which includes -v verbose flag. This option prints test specifics as well as test suite stats.

huangapple
  • 本文由 发表于 2016年11月4日 10:31:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/40414392.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定