Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as an open source contributor and product manager

View project on GitHub

Colorful Test Output

The standard command line use when testing go:

$ go test

Colors your test output according to your terminal configuration.

@rakyll has implemented a cool tool gotest for coloring your test output, so you have passing tests colored green, failing tests marked red etc.

$ gotest

You can customize the colors for failing tests and passing tests via environment variables using the palette of your terminal.

GOTEST_PALETTE="red,green" gotest

The first color being for failures and the second one being for passes.

Colorful terminal test output

To find the colors in for example iTerm.app open the Preferences, your profile and the color tab.

iTerm preferences

Use the names for the colors in the environment variables

And interesting alternative is richgo which has even more options (see: Enriched Test Output).

Resources and References

  1. GitHub: rakyll/gotest