TIL: Colorful test output in Go

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, fail…


This content originally appeared on DEV Community and was authored by jonasbn

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

Resources and References

  1. GitHub: rakyll/gotest

This article was lifted from my TIL collection


This content originally appeared on DEV Community and was authored by jonasbn


Print Share Comment Cite Upload Translate Updates
APA

jonasbn | Sciencx (2021-06-29T19:23:21+00:00) TIL: Colorful test output in Go. Retrieved from https://www.scien.cx/2021/06/29/til-colorful-test-output-in-go/

MLA
" » TIL: Colorful test output in Go." jonasbn | Sciencx - Tuesday June 29, 2021, https://www.scien.cx/2021/06/29/til-colorful-test-output-in-go/
HARVARD
jonasbn | Sciencx Tuesday June 29, 2021 » TIL: Colorful test output in Go., viewed ,<https://www.scien.cx/2021/06/29/til-colorful-test-output-in-go/>
VANCOUVER
jonasbn | Sciencx - » TIL: Colorful test output in Go. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/06/29/til-colorful-test-output-in-go/
CHICAGO
" » TIL: Colorful test output in Go." jonasbn | Sciencx - Accessed . https://www.scien.cx/2021/06/29/til-colorful-test-output-in-go/
IEEE
" » TIL: Colorful test output in Go." jonasbn | Sciencx [Online]. Available: https://www.scien.cx/2021/06/29/til-colorful-test-output-in-go/. [Accessed: ]
rf:citation
» TIL: Colorful test output in Go | jonasbn | Sciencx | https://www.scien.cx/2021/06/29/til-colorful-test-output-in-go/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.