Skip to content
Matthew Holt edited this page Oct 23, 2013 · 2 revisions

Sometimes it's nice to ignore or skip an entire scope or some assertions here and there. This is easy with GoConvey.

Skipping Convey registrations

Changing a Convey() to SkipConvey() prevents the func() passed into that call from running. This also has the consequence of preventing any nested Convey registrations from running. The reporter will indicate that the registration was skipped.

SkipConvey("Important stuff", func() {			// This func() will not be executed!
    Convey("More important stuff", func() {
        So("asdf", ShouldEqual, "asdf")
    })
})

Using SkipConvey() has nearly the same effect as commenting out the test entirely. However, this is preferred over commenting out tests to avoid the usual "declared/imported but not used" errors. Usage of SkipConvey() is intended for temporary code alterations.

Unimplemented Convey registrations

When composing Convey registrations, sometimes it's convenient to use nil instead of an actual func(). Not only does this skip the scope, but it provides an indication in the report that the registration is not complete, and that it's likely your code is missing some test coverage.

Convey("Some stuff", func() {

    // This will show up as 'skipped' in the report
    Convey("Should go boink", nil)

}

Skipping So assertions

Similar to SkipConvey(), changing a So() to SkipSo() prevents the execution of that assertion. The report will show that the assertion was skipped.

Convey("1 Should Equal 2", func() {
    
    // This assertion will not be executed and will show up as 'skipped' in the report
    SkipSo(1, ShouldEqual, 2)

})

And like SkipConvey, this function is only intended for use during temporary code alterations.

End of tutorial

Congrats, you made it! Now go test!

Clone this wiki locally