Closed cwmos closed 3 years ago
Hey, thanks for the feature request. I will leave this issue open for a while to see if there is interest for this feature by other users of the library. I personally like the multiple files today as each external library dependency each have their own separate dependencies. I also think that using the CLI commands would become harder to read. I typically put my mockgen
statements as go generate
directives in source code.
At this time I don't think we will be moving forward with this request. Besides other comments from above there would be no good way to specify flags for each separate mock. I suggest using multiple go:generate
directives.
As far as I can see, if you use gomock in reflect mode, all mocked interfaces that end up in one gomock output file, must come from the same package.
I would like it to be possible to mock interfaces from several packages and let them end up in one gomock output file. For example by:
Why?
Suppose I have a package A that needs mocks of interfaces defined in packages B, C and D.
The way I currently do this, is that I place the mocks for B, C and D in package A in files mock_B_test.go, mock_C_test.go and mock_D_test.go respectively. I do it this way in order to avoid import cycles and to make sure godoc does not create documentation of the mocks.
However, in this example I need to have three different autogenerated mock files in package A. It would be nice if only one file was needed in order not to clutter the source code with more autogenerated files than strictly needed.