MCPcopy
hub / github.com/stretchr/testify / On

Method On

mock/mock.go:369–382  ·  view source on GitHub ↗

On starts a description of an expectation of the specified method being called. Mock.On("MyMethod", arg1, arg2)

(methodName string, arguments ...interface{})

Source from the content-addressed store, hash-verified

367//
368// Mock.On("MyMethod", arg1, arg2)
369func (m *Mock) On(methodName string, arguments ...interface{}) *Call {
370 for _, arg := range arguments {
371 if v := reflect.ValueOf(arg); v.Kind() == reflect.Func {
372 panic(fmt.Sprintf("cannot use Func in expectations. Use mock.AnythingOfType(\"%T\")", arg))
373 }
374 }
375
376 m.mutex.Lock()
377 defer m.mutex.Unlock()
378
379 c := newCall(m, methodName, assert.CallerInfo(), arguments, make([]interface{}, 0))
380 m.ExpectedCalls = append(m.ExpectedCalls, c)
381 return c
382}
383
384// /*
385// Recording and responding to activity

Calls 2

CallerInfoFunction · 0.92
newCallFunction · 0.85