mockery-generate

Generate Go interface mocks with mockery and go:generate.

6|2|Updated Nov 16, 2025
One-click install
npx skills add https://github.com/EricOo0/stock-trading-platform --skill mockery-generate
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: mockery-generate
Source: https://github.com/EricOo0/stock-trading-platform/tree/main/.coco/skills/mockery-generate
Command: npx skills add https://github.com/EricOo0/stock-trading-platform --skill mockery-generate

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill standardizes and automates the generation of mocks for Go interfaces using mockery and go:generate, eliminating manual mock implementations and keeping tests consistent.

Core Features & Use Cases

  • Automatically annotate interfaces with go:generate mockery --name=<Interface> --with-expecter=true
  • Enforce generation of mocks into a mocks subpackage next to the interface
  • Provide testing-ready mocks that are imported and used in unit tests

Quick Start

Identify the interfaces to mock, replace or ensure the go:generate line above each interface, e.g. go:generate mockery --name=YourInterface --with-expecter=true Run go generate ./... to generate or update mocks In tests, import the generated mocks from the mocks package and use the provided New... constructors and EXPECT to configure behaviors

Frequently Asked Questions about mockery-generate

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate mocks for Go interfaces automatically using go:generate?▼

To generate mocks for Go interfaces automatically, you need to add a go:generate mockery comment above each interface definition, then run go generate ./... to create ready-to-use mock implementations in a mocks subpackage for your unit tests.

What is the standard way to structure mockery generated mocks in a Go project?▼

The standard way to structure generated mocks is to place them in a dedicated mocks subpackage located next to the original interface definition, ensuring consistent organization and easy import across your Go project unit tests.

How do I configure mockery to generate expecter mocks for Go unit testing?▼

You configure mockery to generate expecter mocks by adding the --with-expecter=true flag to your go:generate mockery command, which provides EXPECT methods and New... constructors for configuring mock behaviors in your tests.

Can I use mockery with existing Go interfaces without manually writing mock code?▼

Yes, you can use mockery with existing Go interfaces by annotating them with a go:generate line, eliminating manual mock implementations and automatically generating testing-ready mocks that you import directly into your unit tests.

Why does my go generate command not create mocks for my Go interface?▼

Your go generate command may not create mocks if the interface lacks the required go:generate mockery --name=<Interface> annotation, which must be placed directly above the interface definition to trigger mock generation correctly.