我使用testify來測試我的代碼,我想檢查一個函數是否被調用。AssertCalled總是與作證庫失敗
我做了以下內容:
type Foo struct {
mock.Mock
}
func (m Foo) Bar() {
}
func TestFoo(t *testing.T) {
m := Foo{}
m.Bar()
m.AssertCalled(t, "Bar")
}
的錯誤我得到:
Error: Should be true
Messages: The "Bar" method should have been called with 0 argument(s), but was not.
mock.go:419: []
我通話功能「酒吧」,馬上問,如果它被稱爲但是它返回false。 我在做什麼錯? 什麼是正確的方式來測試一個函數是否與testify一起被調用?
謝謝,我也回答了GitHub :) – Buzzy