franela / goblin

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

Gomega really should not panic... #38

Open onsi opened 10 years ago

onsi commented 10 years ago

Gomega handles assertion failures exactly like Goblin's internal assertion library handles assertion failures: by calling a fail method that is provided to it (in Goblin's case it is g.fail which does not panic).

It would be incorrect for Gomega to panic because there is no way for the caller to rescue a panic emitted in a called go routine. This would make your asynchronous test example impossible:

  g.Describe("Numbers", func() {
      g.It("Should add two numbers asynchronously", func(done Done) {
          go func() {
              g.Assert(1+1).Equal(2) //If this line panics there's no way for the test framework to catch it!
              done()
          }()
      })
  })

Would you mind changing the language in the Readme to indicate that this really is not an open issue in Gomega any more? Thanks!