# Testing

> Standards for unit testing, table-driven tests, and mocking in Golang.

- Skill: `fierzone/testing` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add fierzone/testing`
- Raw SKILL.md: https://api.skillmd.com/api/skills/fierzone/testing/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: fierzone (https://skillmd.com/u/fierzone)
- Updated: 2026-09-10
- Page: https://skillmd.com/skills/fierzone/testing

---


# Golang Testing Standards

## **Priority: P0 (CRITICAL)**

## Principles

- **Table-Driven Tests**: The idiomatic way to write tests in Go.
- **Subtests (`t.Run`)**: Run table entries as subtests for better reporting.
- **Parallel Usage**: Use `t.Parallel()` for independent tests to speed up execution.
- **Mock Interfaces**: Mock at the boundaries (interfaces).

## Tools

- **Stdlib**: `testing` package is usually enough.
- **Testify (`stretchr/testify`)**: Assertions (`assert`, `require`) and Mocks.
- **Mockery**: Auto-generate mocks for interfaces.
- **GoMock**: Another popular mocking framework.

## Naming

- Test file: `*_test.go`
- Test function: `func TestName(t *testing.T)`
- Example function: `func ExampleName()`

## Anti-Patterns

- **Sleeping in tests**: Use channels/waitgroups or retry logic.
- **Testing implementation details**: Test public behavior/interface.

## References

- [Table-Driven Tests](references/table-driven-tests.md)
- [Mocking Strategies](references/mocking-strategies.md)

