From bfe1397cc7f239b486536b940aa044e9a8de387f Mon Sep 17 00:00:00 2001 From: feldentm-SAP Date: Mon, 29 Jan 2024 12:58:13 +0100 Subject: [PATCH 1/2] Add call stack to unexpected mock call Make identification of unexpected calls easier --- gomock/controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gomock/controller.go b/gomock/controller.go index 9d17a2f..72a59db 100644 --- a/gomock/controller.go +++ b/gomock/controller.go @@ -206,7 +206,7 @@ func (ctrl *Controller) Call(receiver any, method string, args ...any) []any { // and this line changes, i.e. this code is wrapped in another anonymous function. // 0 is us, 1 is controller.Call(), 2 is the generated mock, and 3 is the user's test. origin := callerInfo(3) - ctrl.T.Fatalf("Unexpected call to %T.%v(%v) at %s because: %s", receiver, method, args, origin, err) + ctrl.T.Fatalf("Unexpected call to %T.%v(%v) at %s because: %s\n from %s", receiver, method, args, origin, err, debug.Stack()) } // Two things happen here: From 552c7689e5feb2bc1e2b98e3e3c24c46882d28bd Mon Sep 17 00:00:00 2001 From: feldentm-SAP Date: Mon, 29 Jan 2024 16:03:28 +0100 Subject: [PATCH 2/2] fix vanished import --- gomock/controller.go | 1 + 1 file changed, 1 insertion(+) diff --git a/gomock/controller.go b/gomock/controller.go index 72a59db..528944c 100644 --- a/gomock/controller.go +++ b/gomock/controller.go @@ -19,6 +19,7 @@ import ( "fmt" "reflect" "runtime" + "runtime/debug" "sync" )