This project was written as part of a training session aiming to provide guidance on how write unit tests in Golang.
This tutorial examples require docker and golang to be installed. It was tested using Go 1.13 for darwin.
The included makefile aims to facilitate trying out the examples
- make test: executes all the test
- make bench: executes all the benchmark
- make godoc: runs a dockerized version of godoc that you can open locally http://localhost:6060
The tests are separated in arrange / act / assert sections to conveniently expose to the reader what's the preconditions or setup for the test, the functionality being tested, and the expected results of the test. This is also a good pattern to follow to ensure your tests are readable and maintainable.
This tutorial is organized in three sections. Feel free to read the examples and comments.