x-mockery

Generates testify-compatible Go mocks with mockery v3 from .mockery.yml.

2|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/pure-golang/level85 --skill x-mockery
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: x-mockery
Source: https://github.com/pure-golang/level85/tree/main/.agents/skills/x-mockery
Command: npx skills add https://github.com/pure-golang/level85 --skill x-mockery

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill solves the problem of writing and maintaining reliable Go unit-test mocks when a consumer needs to stub interface dependencies in a consistent, type-safe way.

Core Features & Use Cases

  • Consumer-side interface mock flow: defines a minimal interface in the package that consumes it, then generates mocks from the root configuration.
  • Mockery v3 + testify integration: produces testify-based mocks with EXPECT() and the New<Type>(t) constructor for mockery v3.
  • Guardrails and validation: ensures you use the project’s centralized .mockery.yml and validates generated output via a post-check script.
  • Run-time return logic: uses RunAndReturn for typed results derived from call arguments.

Quick Start

Run x-mockery to generate a testify mock for a consumer-side interface using the root .mockery.yml, then verify the result with scripts/check-mockery-targets.sh.

Frequently Asked Questions about x-mockery

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

FAQPage Schema
How do I generate testify mocks for Go unit tests using mockery v3?

To generate testify mocks, define a consuming-side interface, run the tool against your centralized .mockery.yml, and use the New<Type>(t) constructor with EXPECT() conventions to stub dependencies in Go unit tests.

How do I stub interface dependencies in Go unit tests with argument-dependent return values?

You stub interface dependencies by using the RunAndReturn method to provide typed results derived from call arguments, allowing your testify mocks to return dynamic values based on inputs during unit tests.

Does mockery v3 work with a centralized .mockery.yml configuration file?

Yes, mockery v3 works with a centralized .mockery.yml file, ensuring consistent mock generation across the project and validating outputs against the configured root targets using a post-check script.

What is the consumer-side interface mocking workflow for Go testify mocks?

Consumer-side mocking defines a minimal interface directly in the consuming package rather than the provider package, then generates testify-compatible mocks from the root configuration to stub dependencies locally.

How do I validate generated testify mocks after running mockery v3?

You validate generated testify mocks by running the provided post-check script, scripts/check-mockery-targets.sh, which verifies that the mock output matches the targets defined in your .mockery.yml.

Can I use mockery v3 to set up single-call expectations in Go testify mocks?

Yes, you can set up single-call expectations in testify mocks by using the EXPECT() convention provided by mockery v3, allowing precise control over interface method calls during unit test execution.