Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit d0755d3

Browse files
committed
Improve mock usability in tests
Add stacktrace on fatal exit of mocked call to allow maintainers of tests using this API to understand what is actually going wrong
1 parent 5b45562 commit d0755d3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

gomock/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func (ctrl *Controller) Call(receiver interface{}, method string, args ...interf
190190
// and this line changes, i.e. this code is wrapped in another anonymous function.
191191
// 0 is us, 1 is controller.Call(), 2 is the generated mock, and 3 is the user's test.
192192
origin := callerInfo(3)
193-
ctrl.T.Fatalf("Unexpected call to %T.%v(%v) at %s because: %s", receiver, method, args, origin, err)
193+
ctrl.T.Fatalf("Unexpected call to %T.%v(%v) at %s because: %s\n from %s", receiver, method, args, origin, err, debug.Stack())
194194
}
195195

196196
// Two things happen here:

0 commit comments

Comments
 (0)