golang-testing

Write and organize Go tests with table-driven patterns, subtests, benchmarks, fuzzing, and coverage.

1|Updated Jan 30, 2021
One-click install
npx skills add https://github.com/fideguch/my_dotfiles --skill golang-testing-fideguch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-testing
Source: https://github.com/fideguch/my_dotfiles/tree/main/claude/skills/golang-testing
Command: npx skills add https://github.com/fideguch/my_dotfiles --skill golang-testing-fideguch

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing robust and maintainable Go code requires a suite of testing patterns that scale from simple unit tests to fuzzing and benchmarks, guided by a TDD mindset.

Core Features & Use Cases

  • Table-driven tests enable concise, scalable coverage across diverse inputs.
  • Subtests and parallel tests help organize scenarios and speed up execution.
  • Benchmarks and fuzz tests validate performance and resilience against unexpected inputs.
  • Clear guidance for applying idiomatic Go testing practices within real projects.

Quick Start

Run go test ./... to execute all tests in the module and view the results.

Frequently Asked Questions about golang-testing

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

FAQPage Schema
How do I write table-driven tests in Go to cover multiple input scenarios?

Table-driven tests in Go use a struct slice to define input cases and expected outputs, iterating through them to execute subtests. This pattern provides concise, scalable coverage across diverse inputs while keeping test logic maintainable.

How do I run benchmarks and fuzz tests in Go to check performance and input resilience?

Go benchmarks and fuzz tests validate performance and resilience against unexpected inputs using the testing package. Benchmarks measure execution time while fuzz tests automatically generate random data to expose edge case failures in your functions.

What is the best way to organize Go subtests and run tests in parallel?

Go subtests organize scenarios hierarchically using the t.Run method, allowing structured test execution. Adding t.Parallel within subtests speeds up execution by running cases concurrently, which is an idiomatic Go testing practice for reliable code.

Does this Go testing pattern require external dependencies or frameworks?

No external dependencies are required. These Go testing patterns rely entirely on the standard library testing package, applying idiomatic practices for table-driven tests, subtests, benchmarks, fuzz tests, and coverage reporting within real projects.

How do I measure code coverage when running tests in a Go module?

Code coverage in a Go module is measured using the testing package flags with the go test command. This reporting validates that your table-driven tests, subtests, and fuzz tests adequately exercise your functions to ensure reliable code.