What’s awesome about Go (golang) is that pretty much everything you need is built into the toolchain.
Running your tests is a simple matter of
go test ./....
Creating basic services such as building a web server is included in the standard library.
While the standard library is great, there’s modules out there that provide enhanced features.
GoTestSum does this for
It’s a simple enhancement that provides a great deal of value.
Let’s check it out.
GoTestSum sits on top of
It provides better, formatted test output, as well as a useful summary of all of your tests.
Behind the scenes it is running
go test --json and then running it through one of several formatters that is offered out of the box.
Here’s a side-by-side example of running
go test and
gotestsum for the static site generator Gotham:
go test output is on the left and
gotestsum output on the right.
For me, the output on the right is more more legible.
Also, a project with as many tests as Gotham generates a lot of output.
The summary shown at the end becomes very useful.
A powerful feature of GoTestSum is the built-in ability to output JUnit. JUnit is an industry standard file format to display test results and timing information. Most CI providers such as CircleCI and Travis CI accept JUnit as an input in order to store and present test metadata to you. CircleCI has docs for this here. GoTestSum can output JUnit with a single flag:
gotestsum --junitfile unit-tests.xml
Information on installing and using GoTestSum can be found on their official GitHub repository. To summarize those, it can be installed with Go by running:
go get gotest.tools/gotestsum