Skip to content
Justice Tech School

Testing with go testPremium

Test files end in _test.go and test functions start with Test and take *testing.T. Table driven tests list inputs and expected outputs in a slice and loop over them. Run with go test ./... and add -race to find data races. This example is shown without output because it is run by go test.

This is a Premium lesson

All the basic lessons are free. Advanced and in-depth lessons, with every example, exercise and quiz, are included with a Premium subscription.

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.