go-table-driven-tests

Installation
SKILL.md

Go Table-Driven Tests

Overview

Table-driven tests are a Go testing idiom that reduces code duplication and makes tests more maintainable. Instead of writing separate test functions for each case, you define a table of test cases and iterate over it.

When to Use Table-Driven Tests

Use table-driven tests when:

  • You find yourself copying and pasting test code
  • You're testing the same function/behavior with multiple inputs
  • You want to add more test cases without writing more test functions
  • Edge cases and boundary conditions need systematic coverage

Do NOT use for: Completely unrelated test scenarios, or when each test requires substantially different setup/teardown logic.

Basic Template (Slice Pattern)

Related skills
Installs
14
Repository
xe/x
GitHub Stars
321
First Seen
Jan 30, 2026