示例代码请访问:github.com/wenjianzhan…
Behavior Driven Development
BDD in Go
项目网站
安装
go get -u github.com/smartystreets/goconvey/convey
package bdd
import (
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestSpec(t *testing.T) {
Convey("Given 2 even numbers", t, func() {
a := 2
b := 4
Convey("When add the two numbers", func() {
c := a + b
Convey("Then the result is still even", func() {
So(c%2, ShouldEqual, 0)
})
})
})
}
输出
=== RUN TestSpec
.
1 total assertion
--- PASS: TestSpec (0.00s)
PASS
Process finished with exit code 0
启动 WEB UI
$GOPATH/bin/goconvey
示例代码请访问:github.com/wenjianzhan…