go-testing

Standardize Go tests with table-driven patterns, t.Run subtests, and benchmarks.

415|44|Updated Mar 18, 2026
One-click install
npx skills add https://github.com/notque/claude-code-toolkit --skill go-testing-notque
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-testing
Source: https://github.com/notque/claude-code-toolkit/tree/main/skills/go-testing
Command: npx skills add https://github.com/notque/claude-code-toolkit --skill go-testing-notque

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Go testing in real-world projects often lacks standardized patterns, leading to flaky tests and inconsistent coverage. This Skill codifies idiomatic Go testing practices to help you write reliable, maintainable tests with proven patterns.

Core Features & Use Cases

  • Table-driven tests with t.Run subtests for clear, data-driven coverage
  • Use of t.Helper() in test helpers to improve failure diagnostics
  • Manual mocking patterns for interfaces to enable isolated testing
  • Benchmarks using modern patterns and race-detection guidance
  • Guidance for integrating synctest patterns for deterministic concurrency (Go 1.25+)
  • Trigger-based discovery via go test, _test.go, and common testing keywords
  • Applicable across Go projects aiming to improve test quality, CI reliability, and documentation of behavior

Quick Start

Run go test in your module to start applying table-driven tests, subtests, and basic benchmarks.

Frequently Asked Questions about go-testing

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

FAQPage Schema
How do I write table-driven tests with t.Run subtests in Go?

Table-driven tests in Go use a slice of structs to define test cases, iterating over them with t.Run subtests to isolate failures. This pattern standardizes data-driven coverage, ensuring consistent test execution across development and CI workflows.

What is the best way to structure manual mocking patterns for Go interfaces?

Manual mocking for Go interfaces involves implementing the interface with a custom test struct. This approach enables isolated testing without external dependencies, ensuring reliable and maintainable mocks across your test suites.

How do I use t.Helper() to improve failure diagnostics in Go tests?

t.Helper() marks test helper functions so failures report the caller's line instead of the helper's line. This improves failure diagnostics by pointing directly to the failing test case, streamlining debugging in complex test suites.

How do I write benchmarks with race detection in Go?

Benchmarks in Go use the Benchmark prefix and testing.B to measure performance. Apply race detection guidance by running tests with the -race flag to identify concurrent data races during benchmarking and standard test execution.

Can I use synctest patterns for deterministic concurrency testing in Go?

Yes, synctest patterns integrate deterministic concurrency testing into Go projects. Available in Go 1.25+, these patterns help control goroutine scheduling, ensuring reliable and predictable testing of concurrent code without flaky behavior.

When should I use t.Run subtests instead of separate test functions?

Use t.Run subtests when grouping related test cases under a single test function, such as in table-driven tests. This approach provides better test organization, allows targeted execution of individual cases, and simplifies failure reporting.