Pre-1.7, calling t.Error after a Test function returned had no effect. Now it causes the test suite to fail, but (confusingly) the cause of the failure isn't reported in any way.
package t_test
import (
"testing"
"time"
)
func TestA(t *testing.T) {
go func() {
time.Sleep(10 * time.Millisecond)
t.Errorf("failed after success")
}()
}
func TestB(t *testing.T) {
time.Sleep(1 * time.Second)
}
$ go version
go version go1.6 linux/amd64
$ go test . -test.v
=== RUN TestA
--- PASS: TestA (0.00s)
=== RUN TestB
--- PASS: TestB (1.00s)
PASS
ok _/usr/local/google/home/dneil/src/testex 1.022s
$ ~/go/bin/go version
go version devel +15285d4 Wed Apr 27 11:08:58 2016 -0700 linux/amd64
$ ~/go/bin/go test . -test.v
=== RUN TestA
--- PASS: TestA (0.00s)
=== RUN TestB
--- PASS: TestB (1.00s)
FAIL
exit status 1
FAIL _/usr/local/google/home/dneil/src/testex 1.013s
The test is clearly at fault, so this becoming a failure isn't a problem at all. However, it's not at all obvious why the test has failed; every test passes and then the test run fails inexplicably.
Pre-1.7, calling t.Error after a Test function returned had no effect. Now it causes the test suite to fail, but (confusingly) the cause of the failure isn't reported in any way.
The test is clearly at fault, so this becoming a failure isn't a problem at all. However, it's not at all obvious why the test has failed; every test passes and then the test run fails inexplicably.