当前位置: 首页 > news >正文

网站推广的方法包括网络品牌营销案例

网站推广的方法包括,网络品牌营销案例,网站建设太难了,怎么建设网站网站GitHub - bytedance/mockey: a simple and easy-to-use golang mock library Go mockito 是什么? mockey是一个简单易用的golang mock库,可以快速方便的mock函数和变量。目前广泛应用于字节跳动服务的单元测试编写。底层是monkey patch,通过在运行时重…

GitHub - bytedance/mockey: a simple and easy-to-use golang mock library

Go mockito 是什么?

 mockey是一个简单易用的golang mock库,可以快速方便的mock函数和变量。目前广泛应用于字节跳动服务的单元测试编写。底层是monkey patch,通过在运行时重写函数指令实现。

  1. 编译时需要关闭inlining和compilation optimization,否则mock可能失败或者报错。有关详细信息,请参阅以下常见问题解答章节。
  2. 在实际编写单元测试的过程中,推荐配合Convey库一起使用。

 

安装

go get github.com/bytedance/mockey@latest

快速指南

import ("fmt""testing". "github.com/bytedance/mockey". "github.com/smartystreets/goconvey/convey"
)func Foo(in string) string {return in
}type A struct{}func (a A) Foo(in string) string { return in }var Bar = 0func TestMockXXX(t *testing.T) {PatchConvey("TestMockXXX", t, func() {Mock(Foo).Return("c").Build()   // mock functionMock(A.Foo).Return("c").Build() // mock methodMockValue(&Bar).To(1)           // mock variableSo(Foo("a"), ShouldEqual, "c")        // assert `Foo` is mockedSo(new(A).Foo("b"), ShouldEqual, "c") // assert `A.Foo` is mockedSo(Bar, ShouldEqual, 1)               // assert `Bar` is mocked})// mock is released automatically outside `PatchConvey`fmt.Println(Foo("a"))        // afmt.Println(new(A).Foo("b")) // bfmt.Println(Bar)             // 0
}

特征

对象

分类

功能细节

函数

基础 mock

普通函数

可变参数函数

普通方法

可变参数方法

嵌套结构体方法

私有类型的导出方法(不同包下)

其他功能

mock 后执行原函数

goroutine 条件过滤

增量改变 mock 行为

获取原函数执行次数

获取 mock 函数执行次数

变量

基础 mock

普通变量

函数变量

 兼容性

OS Support

  • Mac OS(Darwin)
  • Linux
  • Windows

Arch Support

  • AMD64
  • ARM64

Version Support

  • Go 1.13+

License 

 Mockey is distributed under the Apache License, version 2.0. The licenses of third party dependencies of Mockey are explained here.

FAQ 

如何禁用内联和编译优化? 

  1. Command line:go test -gcflags="all=-l -N" -v ./...
  2. Goland:fill -gcflags="all=-l -N" in the Run/Debug Configurations > Go tool arguments dialog box

mock后还是进入了原来的函数?

  1. 尝试使用调试模式。如果能跑通,说明就是问题所在。
  2. 忘记调用了Build(),导致没有实际效果
  3. 目标函数不完全匹配:
    func TestXXX(t *testing.T) {Mock((*A).Foo).Return("c").Build()fmt.Println(A{}.Foo("a")) // enters the original function, because the mock target should be `A.Foo`a := A{}Mock(a.Foo).Return("c").Build()fmt.Println(a.Foo("a")) // enters the original function, because the mock target should be `A.Foo` or extracted from instance `a` using `GetMethod`
    }
  4. 目标函数在其他goroutines中执行:
    func TestXXX(t *testing.T) {PatchConvey("TestXXX", t, func() {Mock(Foo).Return("c").Build()go Foo("a") // the timing of executing 'foo' is uncertain})// when the main goroutine comes here, the relevant mock has been released by 'PatchConvey'. If 'foo' is executed before this, the mock succeeds, otherwise it failsfmt.Println("over")time.Sleep(time.Second)
    }

报错“功能太短无法打补丁”?

  1. 内联或编译优化未禁用:您可以尝试使用调试模式。如果能跑通,说明就是问题所在。请转到常见问题解答的相关部分
  2. 函数真的太短了:意思是目标函数不到一行,导致编译出来的机器码太短。一般两行以上不会出现这个问题
  3. PatchConveyRepeat mocking the same function:以最小单位重复mock同一个函数。如果有这样的需求,请获取Mocker实例并重新mock。
  4. 其他工具mock这个函数:比如monkey或者其他工具mock过这个函数

 

http://www.yayakq.cn/news/843589/

相关文章:

  • 山东神华网站建设南京网站建设小程
  • 俄语网站建设公司建设网站能解决什么问题
  • 电子商务和网络购物网站网站头部设计优化
  • 站点推广是什么意思免费网站免费
  • 网站动态与静态上海那家网站做的好
  • iis默认网站无法访问长春网站建设报价
  • 做旅游网站怎样黑群晖wordpress建站
  • 阳江网站建设 公司价格百度推广电话营销话术
  • 网站公司策划书平面设计公司怎么找客户
  • wordpress 制作网站模板平面设计在家接单收入
  • 公司网站制作需要什么石家庄做网站公司哪家好
  • 常州网站建设解决方案河南网站备案代理
  • 网站开发使用软件有哪些兰州网站建设100
  • 芯片商城网站建设wordpress电视剧主题
  • 网站建设的上市公司wordpress 副标题
  • 合肥企业网站建设yy直播下载
  • 青岛网站建设新元创想广西网站建设服务
  • 做网站的风险做改网站
  • 大连网站设计什么叫做关键词
  • 柳州网站建设招聘asp手机网站自动跳转
  • 网站建设 海外房产祖传做网站
  • 哈尔滨铁路局建设网站wordpress 文章优化
  • 杭州营销网站建设平台深圳营销推广公司
  • 随州市网站建设公司模板网络结构图怎么画
  • 德阳公司做网站西安网络推广营销公司
  • 打广告型的营销网站国际婚恋网站排名
  • 母婴门户网站模板企业如何免费做网站
  • 石家庄网站推广招聘wordpress 网盘插件
  • 软件开发公司是干什么的seo怎么做网站的tdk
  • 国内十大旅游网站排名wordpress标签中文404