go-testing

Standardize Go unit and integration tests with table-driven patterns and test doubles.

121|10|Updated Mar 17, 2026
One-click install
npx skills add https://github.com/sortie-ai/sortie --skill go-testing-sortie-ai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-testing
Source: https://github.com/sortie-ai/sortie/tree/main/.github/skills/go-testing
Command: npx skills add https://github.com/sortie-ai/sortie --skill go-testing-sortie-ai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go testing in Sortie projects often lacks a unified pattern, causing inconsistent tests. This Skill standardizes how unit, integration, and test doubles are written and maintained, ensuring reliable feedback and easier collaboration.

Core Features & Use Cases

  • Table-driven tests with clear structure and parallelization
  • Use of t.Helper, t.Cleanup, and t.Parallel in tests
  • Fixture loading from testdata/ and httptest servers for HTTP adapters
  • Environment-gated integration tests with skip helpers
  • Support for mock/fake/spy test doubles and compile-time interface checks
  • Adherence to adapter conformance and error handling patterns

Quick Start

Run make test to execute the Go tests and follow the repository's testing conventions.

Frequently Asked Questions about go-testing

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

FAQPage Schema
How do I structure table-driven tests in Go with subtests and parallelization?

Table-driven Go tests use a slice of struct cases iterated via t.Run for subtests, calling t.Parallel inside each case to execute concurrently. This pattern standardizes test structure, enabling clear separation of inputs and expected outputs.

What is the best way to mock HTTP adapters in Go unit tests?

Mocking HTTP adapters in Go unit tests uses the httptest package to spin up test servers. Combined with loading fixtures from the testdata directory, this isolates adapter logic and ensures reliable, maintainable HTTP client testing.

How do I gate Go integration tests using environment variables?

Go integration tests are gated using environment variables with skip helpers like t.Skip when the variable is unset. This prevents accidental integration test execution during standard unit test runs, ensuring reliable feedback.

When should I use t.Helper and t.Cleanup in Go test functions?

Use t.Helper in Go test functions to mark test utilities so failures report the calling line, and t.Cleanup to defer resource teardown. These conventions ensure robust error handling and maintainable test suites.

Does this Go testing approach support compile-time interface checks for test doubles?

Yes, compile-time interface checks verify that stubs, fakes, and spies conform to adapter contracts during build. This enforces adapter conformance and error handling patterns, catching interface mismatches before runtime.