franela / goblin

Minimal and Beautiful Go testing framework
MIT License
883 stars 79 forks source link

Add async support. #28

Closed xetorthio closed 10 years ago

xetorthio commented 10 years ago

Now every It that receives a done Done parameter is expected to be async, which means that you either finish the test by calling done() or g.Fail() To do this, panic is not supported anymore, as go doesn't allow to recover panics from goroutines, being outside of a goroutine, which sucks. So now everything relies on Fail function to mark if a test passed or failed. All assertion libraries are expected to call Fail method.

An async test looks like this:

        g.It("Does something async", func(done Done) {
            go func() {
                time.Sleep(100 * time.Millisecond)
                g.Fail("foo is not bar")
            }()
        })