go-testing

Guide Go tests, benchmarks, and fuzzing with testify and go test flags.

Updated Mar 31, 2026
One-click install
npx skills add https://github.com/dotBeeps/hoard --skill go-testing-dotbeeps
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-testing
Source: https://github.com/dotBeeps/hoard/tree/main/morsels/skills/go-testing
Command: npx skills add https://github.com/dotBeeps/hoard --skill go-testing-dotbeeps

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers write, run, and debug Go tests, benchmarks, and fuzzers to detect regressions, concurrency bugs, and performance regressions early in development and CI pipelines.

Core Features & Use Cases

  • Test patterns and conventions: guidance on table-driven tests, subtests, test file layout, and testdata/golden file conventions.
  • Assertions and suites: when to use testify's assert versus require and how to structure testify suites for setup and teardown.
  • Mocking and HTTP testing: interface-based hand-rolled mocks, testify/mock usage, and httptest server/recorder patterns for handler and client tests.
  • Performance and fuzzing: how to write benchmarks that report allocations, run bench comparisons with benchstat, and seed and run fuzz tests with corpus management.
  • Use Case: add comprehensive unit and integration tests for a web service, validate race conditions locally, and produce coverage and benchmark reports for CI-based regression detection.

Quick Start

Run the project's tests with race detection and coverage and generate an HTML coverage report.

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 in Go using the standard testing package?

Table-driven tests in Go use a slice of structs to define test cases, looping over them with subtests via t.Run to isolate failures. This approach standardizes test file layout and validates multiple inputs efficiently.

What is the difference between testify assert and require in Go tests?

Testify require stops test execution immediately on failure, while assert records the failure and continues. Use require for setup conditions and assert for non-critical validations within your Go test suites.

How do I test HTTP handlers in Go using httptest?

Use Go's httptest package to create test servers or response recorders for handler and client testing. This validates HTTP request routing and response payloads without starting a real network server.

How do I run Go benchmarks and compare performance with benchstat?

Run Go benchmarks with go test -bench to measure execution time and memory allocations. Compare benchmark results across code versions using benchstat to detect performance regressions.

Can I detect race conditions in Go code during local testing?

Run go test with the -race flag to detect race conditions and concurrency bugs. This data race detector validates concurrent code execution locally and in CI pipelines.

What is fuzzing in Go and how do I manage the test corpus?

Fuzzing in Go uses randomized inputs to find edge-case bugs. Seed the fuzz test corpus with valid inputs and run go test -fuzz to automatically generate and test new variations.