github地址:https://github.com/smartystreets/goconvey以下是官方列举的goconvey的几个特性:直接集成go test可以管理和运行测试用例提供了丰富的断言函数支持很多 安装go get github.com/smartystreets/goconvey2. "github.com/smartystreets/goconvey/convey")func TestSpec(t *testing.T) {// Only pass t into top-level [image.png]更多请参考官方iwiki:https://github.com/smartystreets/goconvey/wiki/Documentation
go-simplejson - package: git.oschina.net/qiangmzsx/beegofreecache testImport: - package: github.com/smartystreets testImport": [ { "subpackages": [ "convey" ], "package": "github.com/smartystreets --> Fetching updates for github.com/coocood/freecache [INFO] --> Fetching updates for github.com/smartystreets --> Fetching updates for github.com/coocood/freecache [INFO] --> Fetching updates for github.com/smartystreets [INFO] --> Exporting github.com/smartystreets/goconvey [INFO] --> Exporting github.com/garyburd
"github.com/smartystreets/goconvey/convey")func TestAdd(t *testing.T) {Convey("test add", t, func() { "github.com/smartystreets/goconvey/convey"db的mock"github.com/gin-gonic/gin". "github.com/smartystreets/goconvey/convey""github.com/DATA-DOG/go-sqlmock""github.com/jinzhu/gorm"bench
这个工具用起来再接下下面的 go convey 真的非常 nice Go Convey 更好的单测框架 集成了 go test,有丰富的断言框架,还有彩色用例结果 Github 地址 https://github.com/smartystreets /goconvey 安装 go get github.com/smartystreets/goconvey 代码中 import c "github.com/smartystreets/goconvey localhost:9999/ 即可看到具体的单测结果,每一个案例都可以看到是成功还是失败,以及失败的原因 当然,关于 go convey 的具体使用细节和进阶,可以查看地址:https://github.com/smartystreets
goconvey 的安装和基本用法 在项目中使用goconvey 前需要先在项目依赖中添加goconvey,安装命令如下go get github.com/smartystreets/goconvey "github.com/smartystreets/goconvey/convey" ) func TestSpec(t *testing.T) { // Only pass t into top-level "github.com/smartystreets/goconvey/convey",这样是为了方便大家直接使用 goconvey 中的各种定义,无需再像convey.Convey这样加包前缀。
go get github.com/smartystreets/goconvey/convey@v1.7.2还是利用上面的例子,将convey和monkey结合起来使用,改造一下上面的例子,将KPI的返回从 "github.com/smartystreets/goconvey/convey")func TestCalcKPI(t *testing.T) {Convey("简单的测试", t, func()
import ("fmt""github.com/360EntSecGroup-Skylar/excelize""github.com/smartystreets/goconvey/convey""strconv
安装 go get github.com/smartystreets/goconvey 使用示例 我们使用goconvey来为最开始的基础示例中的Split函数编写单元测试。 result = append(result, s) return } 单元测试文件内容如下: // split_test.go import ( "testing" c "github.com/smartystreets
本文大纲如下: goconvey 的 安装命令如下: go get github.com/smartystreets/goconvey 输入命令后,安装过程如下所示: 关于goconvey的使用方法详解 "github.com/smartystreets/goconvey/convey" ) func TestMain(m *testing.M) { // convey在TestMain场景下的入口 "github.com/smartystreets/goconvey/convey",这样是为了方便大家直接使用 convey 包中的各种定义,无需再像 convey.Convey 这样加包前缀。
goconvey:github.com/smartystreets/goconvey,用来组织测试用例,提供了很多断言,兼容go test,有 web ui 。
"github.com/smartystreets/goconvey/convey" "testing" ) func TestNewStudent(t *testing.T) { Convey( PASS: TestScore (0.00s) PASS ok pkg04 0.126s 2.2.2 图形化使用 确保本地有goconvey的二进制 go get github.com/smartystreets
import ( "os" "testing" "github.com/smartystreets/goconvey/convey")// FuzzEncodeJSON fuzzing
go-simplejson - package: git.oschina.net/qiangmzsx/beegofreecache testImport: - package: github.com/smartystreets
"github.com/smartystreets/goconvey/convey" ) var ( outputExpect = "xxx-vethName100-yyy" ) func TestApplyFunc
"github.com/smartystreets/goconvey/convey" ) func Test_Live3(t *testing.T) { patches := NewPatches( "github.com/smartystreets/goconvey/convey" ) func Test_Live(t *testing.T) { ctrl := gomock.NewController
get github.com/prashantv/gostub // monkey go get github.com/bouk/monkey // goconvey go get github.com/smartystreets
"github.com/smartystreets/goconvey/convey")func TestGetBirthdayFromIdNumber(t *testing.T) {Convey("测试从身份证号获取
其他测试继续执行 -v:查看测试结果 -cover:测试代码覆盖率 go test -v -cover type_test.go 2.第三方 BDD框架 项目网站 https://github.com/smartystreets /goconvey 安装 go get -u github.com/smartystreets/goconvey 启动 web Ui $GOPATH/bin/goconvey 反射和UnSafe reflect.TypeOf
"github.com/smartystreets/goconvey/convey""testing")/** * @Description * @Author guirongguo * @Email
https://github.com/go-check/check GoDog:https://github.com/DATA-DOG/godog GoConvey:https://github.com/smartystreets