go-test-table-driven

Consolidate Go test scenarios into a single table-driven structure.

64|9|Updated Mar 27, 2026
One-click install
npx skills add https://github.com/eduardo-sl/go-agent-skills --skill go-test-table-driven
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-test-table-driven
Source: https://github.com/eduardo-sl/go-agent-skills/tree/main/skills/%28testing%29/go-test-table-driven
Command: npx skills add https://github.com/eduardo-sl/go-agent-skills --skill go-test-table-driven

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Table-driven tests help Go developers organize multiple scenarios with a single test function, reducing duplication and improving readability.

Core Features & Use Cases

  • Guidance on when to use table-driven tests vs explicit subtests
  • Best practices for struct design, naming, and test matrices
  • Examples and patterns for refactoring bloated tables and handling edge cases

Quick Start

Describe a Go test you are writing and ask for a table-driven structure example.

Frequently Asked Questions about go-test-table-driven

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

FAQPage Schema
How do I write table-driven tests in Go to reduce duplication?

Table-driven tests in Go consolidate multiple scenarios into a single test function, reducing duplication. You define a struct slice with test cases, loop through them, and run subtests to improve readability and maintainability.

When should I use table-driven tests instead of explicit subtests in Golang?

Use table-driven tests in Golang when organizing multiple scenarios with similar logic to reduce duplication. Explicit subtests are better for highly distinct test cases requiring unique or complex shared setup logic.

What is the best way to structure a Go test matrix for edge cases?

The best way to structure a Go test matrix is using a table-driven design with explicit descriptive test names, minimal loop bodies, and proper wantErr semantics to ensure clear edge-case coverage and maintainability.

How do I handle wantErr semantics in Go table-driven unit tests?

Handle wantErr semantics in Go table-driven unit tests by defining an error expectation field in your test struct, comparing the returned error against this expectation inside the loop, and ensuring explicit descriptive naming for failures.

How do I refactor bloated Go test tables?

Refactor bloated Go test tables by splitting them into smaller logical matrices, ensuring a minimal loop body, extracting shared setup, and applying explicit descriptive test names to maintain readability and edge-case coverage.