pkg / expect

A simple assertion library that you probably shouldn't use.
BSD 2-Clause "Simplified" License
133 stars 4 forks source link

getT call from goroutine #1

Closed smallinsky closed 4 years ago

smallinsky commented 4 years ago

The idea is very smart, unfortunately it will not convert all cases for example following case where the getT function is called from goroutine.

func TestGetTInGoroutine(t *testing.T) {
    t.Run("fistTest", func(t *testing.T) {
        go func() {
            tt := getT()
            if tt != nil {
                tt.Fatal("log from goroutine")
            }
            // test will silently pass.
        }()
    })
}
davecheney commented 4 years ago

This is specifically disallowed because the testing package requires that t.Fatal be called from the main testing goroutine.

Closing, sorry.