Don't panic on nil callback?
abuchanan-nr opened this issue · comments
What if instead of panicing on a nil ...Func
value, you just return the zero values?
Sometimes our tests don't need to return anything, we just want to capture and verify the calls. The mock.calls
data structure is great for that, but adding empty implementations of ...Func
adds boilerplate.
The question is whether people will be surprised by what's going on or not. What do you think?
I think it is an idea worth exploring, but if added to moq
, it should be an opt-in feature which does not change the current default behavior.
See also #36
I would be open to a PR that added this as a flag. -defaults
or similar.
I have a situation, where this feature would be beneficial for me, so I am interested in having this.
See also the (quite old) PR #96 for a potential implementation.
Came here looking for this. As far as I can see this hasn't been implemented yet, right?
Moq now supports a -stub
flag to support this use-case. Example of generated code when flag is specified:
moq/pkg/moq/testpackages/channels/queuer_moq.golden.go
Lines 57 to 74 in 83ab8dd