994 B
994 B
Testing tips, golang edition
Files
Test file should be place in the package directory and should be name using the following convention :
- repo : github.com/go/pkg
- package : github.com/go/pkg/example
- package file : example/pkg.go
- test file : exemple/pkg_test.go
Run
go test github.com/go/pkg/package
fmt.Println is not working
Gniagniagnia, use
t.Log()
or
t.Logf()
also,
go test github.com/go/pkg/package -v
How to fail
Mark test as failed (next tests executed)
t.Fail()
Mark test as failed AND exit
t.FailNow()
Print and mark test as failed
t.Error()
or
t.Errorf()
Print, mark test as failed AND exit
t.Fatal()
or
t.Fatalf()