Comments (6)
测试了一下在go test 与 dlv 的表现,发现是内联函数导致的
dlv 默认关闭了内联函数优化
所以 go test 的时候加上 -gcflags="all=-N -l" 就可以了
from gomonkey.
from gomonkey.
测试了一下,如果直接跑单元测试的话,进不去gomonkey.ApplyMethod
但是如果开debug的话,又可以
`pathes := gomonkey.ApplyMethod(reflect.TypeOf(&http.Client{}), "Do", func(client *http.Client, req *http.Request) (*http.Response, error) {
log.Println("enter gomonkey")
return nil, errors.New("mock http request failed")
})
defer pathes.Reset()`
如上代码,直接run不会打印enter gomonkey,但是debug下可以打印出来。。。
from gomonkey.
兄弟,我也是这个问题,有解吗
而且我现在跑1.13.5也有同样的问题了
from gomonkey.
前两天试过了,gomonkey自带的所有用例,在go1.14版本都能执行通过
from gomonkey.
测试了一下在go test 与 dlv 的表现,发现是内联函数导致的
dlv 默认关闭了内联函数优化
所以 go test 的时候加上 -gcflags="all=-N -l" 就可以了
此方法可行,close
from gomonkey.
Related Issues (20)
- please add ApplyPrivateMethodFunc and ApplyPrivateMethodReturn
- 是否有并发问题 HOT 4
- 是否有人用gomonkey来实现游戏服务器热更新?
- Why ApplyFunc mocked func returns the same result in a for loop? HOT 1
- MacOS 上的 permission denied 问题,也可能和 cgo 有关 HOT 8
- why patches.Reset not effective? HOT 1
- panic with SIGBUS HOT 6
- MacOS ARM64 兼容性问题 HOT 6
- macos m2 兼容性问题 HOT 6
- 打桩的方法内仅执行 return 语句,打桩没有生效 HOT 2
- panic: runtime error: index out of range [0] with length 0 [darwin/arm64] [M1] HOT 8
- how to mock func which as a param in another func HOT 1
- mac os m1 ApplyFuncReturn not work and unit test many panic HOT 5
- i solve it successfully in mac M1 by update new gomonkey version for permission deny error HOT 3
- 内联优化导致apply func失效 HOT 3
- gomonkey 中有异步携程时,mock的方法会失效 HOT 3
- Private method tests fail on Linux/Arm64 HOT 2
- Is it possible to add a `init` func to check whether `-gcflags=all=-l` is in `os.Args`? HOT 1
- gomonky 为泛型结构体的方法打桩不生效 HOT 2
- Running multiple cases at the same time and reporting errors: panic: double seq is less than call seq HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gomonkey.