Closed youthlin closed 3 years ago
func MyFun() int { return 1 } func TestMock(t *testing.T) { Convey("mock", t, func() { p := gomonkey.ApplyFunc(MyFun, func() int { return 11 }) i := MyFun() So(i, ShouldEqual, 11) // ok p.Reset() i = MyFun() So(i, ShouldEqual, 1)// fails, got 11 }) }
调用 Reset 方法后,还是走了打桩逻辑,而没有调用原来的函数? Reset 不是还原的含义吗,那需要怎么还原呢? (may be similar to https://github.com/agiledragon/gomonkey/issues/21)
Reset
我的锅,没问题
调用
Reset
方法后,还是走了打桩逻辑,而没有调用原来的函数? Reset 不是还原的含义吗,那需要怎么还原呢? (may be similar to https://github.com/agiledragon/gomonkey/issues/21)