testing

Standardize Go unit and integration tests using fakes, goleak, and golden files.

2|Updated Feb 6, 2026
One-click install
npx skills add https://github.com/air-gapped/cooked --skill testing-air-gapped
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/air-gapped/cooked/tree/main/.claude/skills/testing
Command: npx skills add https://github.com/air-gapped/cooked --skill testing-air-gapped

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill codifies best practices for Go testing, ensuring tests use fakes over mocks, leverage golden files, and detect goroutine leaks early to improve reliability and maintainability.

Core Features & Use Cases

  • Fakes over mocks: prefer real implementations when feasible to keep tests fast and meaningful.
  • Stdlib-first testing: prioritize Go's standard testing package and built-in tooling.
  • Quality checks: promote goleak, httptest, and golden file patterns to catch leaks and regressions.
  • Use Case: a Go project migrating from heavy mocks to fakes for service boundaries to achieve deterministic tests.

Quick Start

Run the project tests with go test ./... and enable race detection to ensure thread-safety.

Frequently Asked Questions about testing

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

FAQPage Schema
How do I use fakes instead of mocks in Go testing?

Golden files store expected test output, allowing Go tests to compare actual results against saved fixtures to catch regressions. This pattern standardizes output validation by recording known good data and diffing future test runs against it.

What is the best way to detect goroutine leaks in Go tests?

Goroutine leaks are detected using goleak checks at the end of Go tests to verify all spawned routines terminate. Integrating goleak ensures tests clean up properly, preventing resource exhaustion and unpredictable behavior in service boundaries.

Can I test HTTP handlers in Go without external dependencies?

HTTP handlers are tested using the standard library httptest utility to simulate servers and clients. This built-in tooling allows developers to send mock requests and record responses, ensuring fast and predictable test execution without external dependencies.

How do I run Go tests with race detection for thread safety?

Run Go tests with race detection by executing the command with the race flag to identify concurrent access issues. This standard library feature ensures thread safety by detecting data races during test execution across project boundaries.