Skip to content

You're holding it wrong

Matthew Holt edited this page Feb 3, 2014 · 9 revisions

When a customer emailed Steve Jobs about bad reception on the iPhone 4, Jobs replied and basically told him, you're holding it wrong.

Similarly, here are some of the wrong ways to "hold" GoConvey, some of which are not very obvious (and understandably so).

• Go files not in src folder in a Go workspace

When using the web UI, Go files being tested must be in the GOPATH under the src directory. The server expects the src directory to be present after the GOPATH so it can determine the full package name.

:= instead of = to initialize state

Remember, top-level Conveys are executed once for each nested Convey. This could cause variables to be unexpectedly re-used or overwritten across different tests (uh oh!). But this is actually incredibly convenient (see the linked article for why).

• More than one level of Convey() in loop

Something like this:

Convey("Level 1", t, func() {
    for i := 0; i < 3; i++ {
        Convey("Level 2", func() {
            Convey("Level 3", func() {
                So(true, ShouldBeTrue)
            })
        })
    }
})

won't produce as many assertions as you think. Want to try and figure out why?

• Calling panic(nil)

Never, never, never call panic(nil) because GoConvey can't recover the error (it thinks the Convey passed) see issue 98 and especially this Stack Overflow question.

Clone this wiki locally