Giter Club home page Giter Club logo

Comments (6)

kakisong avatar kakisong commented on May 13, 2024 3

测试了一下在go test 与 dlv 的表现,发现是内联函数导致的
dlv 默认关闭了内联函数优化
所以 go test 的时候加上 -gcflags="all=-N -l" 就可以了

from gomonkey.

linqh1 avatar linqh1 commented on May 13, 2024

image

from gomonkey.

linqh1 avatar linqh1 commented on May 13, 2024

测试了一下,如果直接跑单元测试的话,进不去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.

kakisong avatar kakisong commented on May 13, 2024

兄弟,我也是这个问题,有解吗
而且我现在跑1.13.5也有同样的问题了

from gomonkey.

agiledragon avatar agiledragon commented on May 13, 2024

前两天试过了,gomonkey自带的所有用例,在go1.14版本都能执行通过

from gomonkey.

linqh1 avatar linqh1 commented on May 13, 2024

测试了一下在go test 与 dlv 的表现,发现是内联函数导致的
dlv 默认关闭了内联函数优化
所以 go test 的时候加上 -gcflags="all=-N -l" 就可以了

此方法可行,close

from gomonkey.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.