The structs testing.T
and testing.B
both have a .Log
and .Logf
method that sound to be what you are looking for. .Log
and .Logf
are similar to fmt.Print
and fmt.Printf
respectively.
See more details here: http://golang.org/pkg/testing/#pkg-index
fmt.X
print statements do work inside tests, but you will find their output is probably not on screen where you expect to find it and, hence, why you should use the logging methods in testing
.
If, as in your case, you want to see the logs for tests that are not failing, you have to provide go test
the -v
flag (v for verbosity). More details on testing flags can be found here: https://golang.org/cmd/go/#hdr-Testing_flags