You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would imagine a lot of mocks are generated to be used in _test files, with _test package names. To generate one using mockery is a bit cumbersom. ie this is great mockery --inpackage --name NodeAndOptionsGetter but will generate a mock as the main package, meaning having to import it to *_test tests (not the end of the world I know)
To get the same mock, with the same MockNodeAndOptionsGetter name, in the same directory, with the same mock_ prefix, but with the _test suffix, and using the _test package, this is what you seemingly have to write:
That's a lot of boilerplate, when tbh I would have thought the --testonly flag would do it all (which in fact on it's own is a compile error due to it not bing in a _test.go file). Is there a better way to do it that I'm not seeing?
Version
v2.10.0
The text was updated successfully, but these errors were encountered:
So there have been requests in the past to add a --packagesuffix option which I previously put on hold because I wasn't sure how popular such a feature would be, and to be honest it's not requested that much because in my experience most people write their test files to be in the same package as the source code. But, I know both standards are used variously in the community.
If you want to add a PR for that flag I think that'll solve your problem.
I would imagine a lot of mocks are generated to be used in _test files, with _test package names. To generate one using mockery is a bit cumbersom. ie this is great
mockery --inpackage --name NodeAndOptionsGetter
but will generate a mock as the main package, meaning having to import it to *_test tests (not the end of the world I know)To get the same mock, with the same MockNodeAndOptionsGetter name, in the same directory, with the same mock_ prefix, but with the _test suffix, and using the _test package, this is what you seemingly have to write:
mockery --output ./ --name NodeAndOptionsGetter --outpkg handler_test --filename mock_NodeAndOptionsGetter_test.go --structname MockNodeAndOptionsGetter
That's a lot of boilerplate, when tbh I would have thought the --testonly flag would do it all (which in fact on it's own is a compile error due to it not bing in a _test.go file). Is there a better way to do it that I'm not seeing?
Version
v2.10.0
The text was updated successfully, but these errors were encountered: