Closed yurii-vyrovyi closed 1 year ago
I'm open to the idea. I think generating mocks in-package is generally the safer way to do this because of the cyclic dependency issue you mentioned. If we add this feature, I'd like it to be part of the packages
feature first but then also backport it if needed.
Sounds great. As for me this will be a point when I want to switch to mockery
from mockgen
. I really like strong typization in mockrey
but we need to keep code clean. I hope it will be soon ;)
I can't give a good estimate on when this would be done, we need to stabilize the packages
feature first. Adding this functionality is kind of non-trivial, but I do see the benefit in it.
Closing this as a duplicate of https://github.com/vektra/mockery/issues/322
Description
I want to generate all mocks into one file to avoid garbaging a folder. I have a lot of interfaces in my package and I have a unit tests in the same package. So, if I generate mocks into sub-package I get a cyclic dependency as
mypackage
refers tomocks
whilemocks
importsmypackage
due to data types.worker.go
mock_repository_one.go
Of course I can move all interfaces definitions to some other folder but I prefer not to change a project structure only because of mocks. Another solution is to place mocks into
mypackage
. Then I haveThat's better from imports prospective but the more interfaces I have the more garbaged my package will be.
Proposal
Can we have a config that will allow to generate all mocks into one file?