Rather than returning the zero-value for unmocked methods, I often want my mocks to be very loud when a method is called on them that I haven't mocked out. As far as I can tell, the only way to do that is either (1) mock every method with a panic manually, or (2) create a "panic on everything type" and then wrap it with NewMockXFrom(panicOnEverythingType{}).
I've been thinking it might be nice to include support for generating panicking types in go-mockgen. I can think of two ways to do that. (A) generate another constructor like NewPanickingMockX, or (B) add a configuration parameter that lets you generate the NewMockX constructor as the panicking version, like go-mockgen -when-unmocked panic or go-mockgen -when-unmocked zerovalue (the current behavior).
Thoughts on whether you think something like this might be worth adding?
Rather than returning the zero-value for unmocked methods, I often want my mocks to be very loud when a method is called on them that I haven't mocked out. As far as I can tell, the only way to do that is either (1) mock every method with a panic manually, or (2) create a "panic on everything type" and then wrap it with
NewMockXFrom(panicOnEverythingType{})
.I've been thinking it might be nice to include support for generating panicking types in
go-mockgen
. I can think of two ways to do that. (A) generate another constructor likeNewPanickingMockX
, or (B) add a configuration parameter that lets you generate theNewMockX
constructor as the panicking version, likego-mockgen -when-unmocked panic
orgo-mockgen -when-unmocked zerovalue
(the current behavior).Thoughts on whether you think something like this might be worth adding?