smartystreets / goconvey

Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go.
http://smartystreets.github.io/goconvey/
Other
8.23k stars 554 forks source link

A possible FAQ question #655

Open davecb opened 2 years ago

davecb commented 2 years ago

I have a program that communicated between threads via a channel. To test an error condition in the receiver, I wrote

Convey("Passing bad operations to send should panic worker", func(c C) {
    // the panic happens in worker(), not send,
    c.So(func() { r.send(-1, Err, 1) }, ShouldPanic)
})

r.send sends an illegal -1, the worker thread duly panics, and send returns without error, rather than reporting that a different thread panicked.

How do I construct a test that detects a panic in another thread? Can I?