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

Table driven tests #577

Closed hzwwen closed 5 years ago

hzwwen commented 5 years ago

Hi, according to originally posted by @mdwhatcott in https://github.com/smartystreets/goconvey/issues/364#issuecomment-157253491. I found some unexpected output from the code below.

func TestName(t *testing.T) {
    call1 := 0
    call2 := 0
    convey.Convey("root", t, func(c convey.C) {
        for i := 0; i < 3; i++ {
            c.Convey(fmt.Sprintf("i: %d", i), func(c convey.C) {
                call2++
            })
        }
        call1 ++
    })
    t.Logf("call1: %d", call1) // call1: 3      why the output is 3? 1 are expected.
    t.Logf("call2: %d", call2) // call1: 3
}
mdwhatcott commented 5 years ago

@hzwwen - Wow, not sure.

cbandy commented 5 years ago

https://github.com/smartystreets/goconvey/wiki/Execution-order

hzwwen commented 5 years ago

@cbandy Thanks.