agiledragon / gomonkey

gomonkey is a library to make monkey patching in unit tests easy
MIT License
1.96k stars 179 forks source link

mock not effect, but effected in debug mode #15

Closed kakisong closed 4 years ago

kakisong commented 4 years ago
func A() {
    fmt.Println("real function")
}
func TestA(t *testing.T) {
    gomonkey.ApplyFunc(A, func() {
        fmt.Println("mock function")
    })
    A()
}

when run this test case, it print real function when debug this test case, it print mock function

Suvirap commented 3 years ago

我也遇到了这个问题, 所以是啥原因啊?或者说该怎么生效呢?

betterwinsone commented 1 year ago

@kakisong 我也遇到这个问题,请问你是怎么解决的