ultroncore/claude-skill-vault/mockery-go-mocking
Claude Code and agent skill by ultroncore/claude-skill-vault
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Generate type-safe interface mocks for Go tests with Mockery — no hand-written boilerplate, full testify integration
Install
npx vskill@latest install ultroncore/claude-skill-vault/mockery-go-mockingSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as ultroncore/claude-skill-vault/mockery-go-mocking.
Mockery — Go Interface Mock Generation
Overview
Mockery is a mock generator for Go that automatically generates mock implementations of interfaces using testify/mock. Instead of writing verbose mock structs by hand, you annotate interfaces with a //go:generate mockery comment and run go generate. The result is a fully type-safe mock that integrates with testify assertions.
When to Use
- Unit testing Go code that depends on interfaces (repositories, HTTP clients, services)
- Replacing real implementations with controlled doubles in tests
- Verifying that methods were called with specific arguments
- Setting up expected return values and errors in service-layer tests
- Avoiding network/database calls in fast unit tests
Installation
Key Patterns
Configure mockery (.mockery.yaml)
Annotate interfaces for generation
Use mocks in tests (with Expecter — recommended)
Match any argument with matchers
Multiple calls and call ordering
Mock returning a function (dynamic responses)
Makefile integration
Common Pitfalls
- Pass `t` to `NewMock`: Using
mocks.NewMockUserRepository(t)(notnew(mocks.MockUserRepository)) automatically callsAssertExpectations(t)at end of test. - `EXPECT()` vs `On()`: Prefer the type-safe
EXPECT()Expecter API — it catches wrong argument types at compile time.On()is stringly-typed and error-prone. - Regenerate after interface changes: Mocks go stale when interfaces change. Add
go generate ./...to your pre-commit hook or CI. - Commit generated mocks: Generated mock files should be committed so CI doesn't require mockery installed. Regenerate locally after changes.
- Don't mock types you don't own: Only mock interfaces defined in your own codebase. For third-party types, wrap them in your own interface first.
Related Skills
- vitest-testing — JavaScript/TypeScript mocking (Vitest's
vi.fn()) - testcontainers-integration — when mocks aren't enough and you need a real database
- go-microservices — Go service patterns that pair with mockery testing
GitNexus Index
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/backend/mockery-go-mocking/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/ultroncore/claude-skill-vault/mockery-go-mocking)