Testing is a critical ritual of modern software development practices. Go brings testing directly into the development cycle by offering an API and command-line tool to seamlessly create and integrate automated test code. Here we will cover the Go testing suite, including the following:
Prior to writing any test code, let's take a detour to discuss the tooling for automated testing in Go. Similar to the
go build command, the
go test command is designed to compile and exercise test source files in specified packages, as illustrated in the following command:
$> go test .
The previous command will exercise all test functions in the current ...