Search code examples
unit-testingtestinggoreportcommand-line-interface

Recommendation for `go test` CLI test reporter


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.


Solution

  • 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. "