go-testing-code-review

Audit Go test files for table-driven structure and proper assertions.

75|9|Updated Dec 21, 2025
One-click install
npx skills add https://github.com/anderskev/beagle --skill go-testing-code-review
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-testing-code-review
Source: https://github.com/anderskev/beagle/tree/main/skills/go-testing-code-review
Command: npx skills add https://github.com/anderskev/beagle --skill go-testing-code-review

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It provides guidance for structuring Go tests with table-driven tests, subtests, and cleanup, to improve readability and coverage.

Core Features & Use Cases

  • Table-Driven Tests: Use structured cases and t.Run for parallel execution.
  • Assertions: Clear, descriptive messages.
  • Cleanup: Ensure proper resource cleanup via t.Cleanup.

Quick Start

Inspect a Go test file and ensure it follows table-driven patterns and proper cleanup.

Frequently Asked Questions about go-testing-code-review

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

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

Table-driven tests in Go use a slice of test cases with input and expected output fields, executed in a loop with t.Run for each case. This pattern improves readability, reduces code duplication, and makes it easy to add new test scenarios by simply adding rows to the table.

What's the best way to structure Go test files for parallel execution?

Use t.Run subtests with t.Parallel to run test cases concurrently within table-driven patterns. Each subtest receives its own copy of loop variables, avoiding race conditions and speeding up test execution across multiple cores.

How do I properly clean up resources in Go tests?

Register cleanup functions with t.Cleanup instead of defer statements. This ensures teardown runs in reverse order of registration, handles panics safely, and isolates cleanup logic from test setup, improving reliability and maintainability.

Why should Go tests use descriptive assertion messages?

Clear, descriptive error messages in assertions help identify exactly what failed and why when tests break. Combined with table-driven test case names, they reduce debugging time and make test failures immediately actionable.

Can I use interface-based mocks in table-driven Go tests?

Yes, interface-based mocks work well in table-driven tests by storing mock instances in test case structs. This approach isolates mock behavior per case, avoids shared mutable state, and keeps test cases independent and reproducible.