testing-patterns

Apply Go table-driven tests and Mockery v3.5 mocks.

Updated Feb 18, 2026
One-click install
npx skills add https://github.com/riddopic/cc-tools --skill testing-patterns-riddopic
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing-patterns
Source: https://github.com/riddopic/cc-tools/tree/main/.claude/skills/testing-patterns
Command: npx skills add https://github.com/riddopic/cc-tools --skill testing-patterns-riddopic

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers write more robust, maintainable, and efficient Go tests by applying established patterns and best practices, reducing bugs and improving code quality.

Core Features & Use Cases

  • Table-Driven Tests: Implement the standard Go pattern for organizing test cases.
  • Mocking with Mockery: Integrate Mockery v3.5 for creating mock objects and defining expectations.
  • Test Organization & Execution: Provides guidance on test structure, coverage, and execution commands.
  • Use Case: When writing a new feature, use this Skill to structure your unit tests using table-driven tests and generate mocks for external dependencies.

Quick Start

Apply the table-driven test pattern to your Go test file.

Frequently Asked Questions about testing-patterns

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

FAQPage Schema
How do I write table-driven tests in Go?

Table-driven tests in Go organize test cases into a struct slice, iterating through each to execute assertions. This pattern standardizes test logic, making unit tests more maintainable and deterministic across multiple input scenarios.

How do I generate mocks in Go using Mockery?

Mockery v3.5 generates mock objects by scanning interfaces in your Go codebase. You run specific generation commands to create mock implementations, allowing you to define expectations and isolate dependencies during unit testing.

What is the best way to structure Go unit tests for maintainability?

The best way to structure Go unit tests involves using table-driven tests and setting up clear test fixtures. Organizing tests this way separates test data from execution logic, improving coverage and reducing bugs.

Does Mockery v3.5 work with existing Go test fixtures?

Yes, Mockery v3.5 integrates with existing Go test fixtures by generating mocks for external dependencies. You can define expectations on these generated mocks within your current test setup to ensure deterministic test execution.

Why are my Go table-driven tests failing with shared variables?

Go table-driven tests fail when test cases share mutable state or loop variables without proper isolation. Creating fresh test fixtures and defining strict mock expectations for each iteration ensures deterministic and maintainable test execution.