Agent skill · software engineering · affaan-m
golang-testing
Go testing best practices including table-driven tests, test helpers, benchmarking, race detection, coverage analysis, and integration testing patterns. Use when writing or improving Go tests.
Why this skill is useful
Provides Go-specific testing patterns and practices that enhance the AI's ability to generate idiomatic Go tests.
What it needs
About 3k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.
What this skill does
Go Testing This skill provides comprehensive Go testing patterns extending common testing principles with Go-specific idioms. Testing Framework Use the standard go test with table-driven tests as the primary pattern. Table-Driven Tests The idiomatic Go testing pattern: Benefits: Easy to add new test cases Clear test case documentation Parallel test execution with t.Parallel() Isolated subtests with t.Run() Test Helpers Use t.Helper() to mark helper functions: Benefits: Correct line numbers in test failures Reusable test utilities Cleaner test code Test Fixtures Use t.Cleanup() for resource cleanup: Race Detection Always run tests with the -race flag to detect data races: In CI/CD: Why: Detects concurrent access bugs Prevents production race conditions Minimal performance overhead in tests Coverage Analysis Basic Coverage Detailed Coverage Report Coverage Thresholds Benchmarking Run benchmarks: Compare benchmarks: Mocking Interface-Based Mocking Integration Tests Build Tags Run integration tests: Test Containers Test Organization File Structure Package Naming Common Patterns Testing HTTP Handlers Testing with Context Best Practices 1. Use t.Parallel() for independent tests 2. Use testing.Short() to skip slow tests 3. Use t.TempDir() for temporary directories 4. Use t.Setenv() for environment variables 5. Avoid init() in test files 6. Keep tests focused - one behavior per test 7. Use meaningful test names - describe what's being tested When to Use This Skill Writing new Go tests Improving test coverage Setting up test infrastructure Debugging flaky tests Optimizing test performance Implementing integration tests
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills affaan-m/golang-testing--9d51e9