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

Function TestArgumentMatcherToPrintMismatch

mock/mock_test.go:2229–2246  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2227}
2228
2229func TestArgumentMatcherToPrintMismatch(t *testing.T) {
2230 t.Parallel()
2231
2232 defer func() {
2233 if r := recover(); r != nil {
2234 matchingExp := regexp.MustCompile(
2235 `\s+mock: Unexpected Method Call\s+-*\s+GetTime\(int\)\s+0: 1\s+The closest call I have is:\s+GetTime\(mock.argumentMatcher\)\s+0: mock.argumentMatcher\{.*?\}\s+Diff:.*\(int=1\) not matched by func\(int\) bool\nat: \[[^\]]+mock\/mock_test.go`)
2236 assert.Regexp(t, matchingExp, r)
2237 }
2238 }()
2239
2240 m := new(timer)
2241 m.On("GetTime", MatchedBy(func(i int) bool { return false })).Return("SomeTime").Once()
2242
2243 res := m.GetTime(1)
2244 require.Equal(t, "SomeTime", res)
2245 m.AssertExpectations(t)
2246}
2247
2248func TestArgumentMatcherToPrintMismatchWithReferenceType(t *testing.T) {
2249 t.Parallel()

Callers

nothing calls this directly

Calls 8

RegexpFunction · 0.92
EqualFunction · 0.92
MatchedByFunction · 0.85
OnceMethod · 0.80
ReturnMethod · 0.80
GetTimeMethod · 0.80
AssertExpectationsMethod · 0.65
OnMethod · 0.45

Tested by

no test coverage detected