- Ending a file’s name with
_test.gotells thego testcommand that this file contains test functions. - Use function name like
TestSTH, passt *testing.Tas parameter - Example:
package main
import "testing"
func TestAdd(t *testing.T) {
if add(1, 2) != 3 {
t.Fail()
}
}