mock
mock copied to clipboard
`t.Helper()` equivalent for mocks
Requested feature Mark a mock configuration helper function as such so that error traces point back to the call to this mock configuration helping function instead of the call to EXPECT()
.
Why the feature is needed Error logs will always show the trace pointing to the EXPECT()
call even if it is in a shared mock configuration helping function. As far as I have searched, there is no way to mark a 'mock configuration helper function' as such even if using t.Helper()
.
(Optional) Proposed solution
- Detect when
t.Helper()
has been called and adapt error stack traces with it, or - Define a new method
Helper()
on the controller, or - Define a new method
Helper()
on generated mocks
I think in order to not change expectations on how people use the library today it would need to be your second or third idea. I would not want to change existing call stacks without more research. I will leave this issue open to see if it gets traction from more in the community.