Go Code Snippets
Simple Unit Test
This is what a basic unit test looks like in Go. It must exist in a file named with the form *_test.go
, and the name of each test must follow the form TestXxx
where the first letter after "Test" is capitalized. Execute go test
in the terminal to run unit tests. A t.Error(str)
is equivalent to a t.Log(str)
followed by a t.Fail()
.