-
Notifications
You must be signed in to change notification settings - Fork 441
Description
Summary
I’d like to request support for generating mocks from interfaces explicitly annotated with a specific comment tag, such as @mockery:generate
.
Background
In my current workflow, I use go:generate
to trigger mock generation for selected interfaces in a large repository. However, managing inclusion and exclusion through regex patterns has proven difficult due to:
- Not all interfaces require mocks.
- Interface names do not follow consistent patterns that are easily targeted via regex.
Proposed Solution
Introduce an option in the mockery.yml
configuration file:
annotation: true
When annotation: true
is set, mockery will only generate mocks for interfaces that include a specific comment annotation above them (e.g., // @mockery:generate
). This could look like:
// @mockery:generate
type MyInterface interface {
...
}
Question
Is something like this currently possible with mockery, or perhaps already being planned? I couldn't find any mention of annotation-based
generation in the documentation, so I’m wondering if there's an existing or alternative approach to achieve this use case.