smartystreets / goconvey

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

If func So 's first argument is void interface, how to make So work? #546

Closed KielChan closed 6 years ago

KielChan commented 6 years ago

if i have function like this:

func DemoVoidReturn(){
    fmt.Println("test empty return")

    if err := doSomething(); err != nil{
        panic("do something failed")
    }
}

and i want to test this panic.

how to use So to test it?

mdwhatcott commented 6 years ago

Your function in a void (no return values), niladic (no input parameters) function and the perform the assertion.

So(wrapperFunction, should.Panic)