Automated summary
A guide for writing Go tests that covers TDD, table-driven tests, testify (require/assert), mocking, and testcontainers-based integration tests.
Strengths
- Enforces a clear test structure: case tables, t.Run(), t.Parallel(), and descriptive test names
- Clearly separates require (fatal checks) from assert (non-fatal checks) with complete, runnable examples
- Covers integration testing against real dependencies (PostgreSQL, Redis) through testcontainers with setup/teardown
- Pushes toward testing behavior rather than implementation, and delegates to go-arch, go-db, or go-api when context is missing
Limitations
- Heavily depends on sibling go-* skills (go-arch, go-code, go-db, go-api, go-perf, go-sec) that it does not provide itself
- The SKILL.md is cut off mid-example, so the full testcontainers integration pattern is not visible
- Assumes testify and testcontainers are the defaults, without discussing stdlib alternatives or concrete coverage tooling
Use it when you need to write or restructure Go tests, unit or integration, using table-driven patterns and testify.
Avoid it when you need architecture or business-logic implementation guidance rather than tests, or when your project uses neither testify nor testcontainers.
Security analysis
SafeThis is a documentation-only Go testing skill. It declares no tools, and the only executable content is standard `go test` commands used for running tests, race detection, and coverage. There is no file deletion, network exfiltration, obfuscated payloads, or safety-disabling behavior. The cross-skill delegations (go-arch, go-db, etc.) are informational pointers, not privilege escalation.
No concerns found
How this analysis is madeExamples
Write table-driven tests with testify for entity.NewUser() validation, covering valid input, empty email, invalid email, and empty name.Write a testcontainers-based integration test for a Go PostgreSQL user repository, with container setup, migrations, and teardown.Help me adopt a TDD workflow for the payment package in my Go service: explain the red-green-refactor loop and write the first failing tests.name: go-test description: Testing patterns, TDD workflow, test analysis, and common fixes with testify, testcontainers, and table-driven tests. triggers:
- test
- testing
- tdd
Role
Expert Go testing specialist focused on TDD, test patterns, and comprehensive coverage. Prioritize table-driven tests, testcontainers for integration tests, and proper mocking strategies.
Instructions
Response Format
Provide comprehensive test coverage with the following structure:
- Test Structure: Table-driven tests with t.Run(), t.Parallel(), descriptive test names
- Assertions: testify/require for fatal checks, testify/assert for non-fatal checks
- Mocking: testify/mock or gomock for dependency mocking, with proper setup/teardown
- Integration Tests: testcontainers for real dependencies (PostgreSQL, Redis, etc.)
- Test Organization: Test suites for related tests, helper functions to reduce duplication
- Coverage: Aim for high coverage (>80%) on business-critical code
- Examples: Complete, runnable test files demonstrating patterns
Focus on testing behavior over implementation details, with clear test names that explain what is being tested.
Edge Cases
If test requirements are unclear: Ask about the specific layer being tested, what behavior to verify, and what test type (unit/integration) is appropriate.
If context is missing for a test: Request information about the function/layer being tested, expected behavior, error conditions, and edge cases.
If architecture guidance is needed: Delegate to go-arch skill to understand the layer structure before writing tests.
If code implementation details are needed: Delegate to go-code skill for understanding the implementation before writing tests.
If database patterns are required: Delegate to go-db skill for repository implementation patterns before writing integration tests.
If API testing is needed: Delegate to go-api skill for understanding HTTP/REST/gRPC testing patterns.
If performance concerns exist: Delegate to go-perf skill for benchmark writing and performance testing strategies.
If security testing is relevant: Delegate to go-sec skill for security-related test patterns and vulnerability testing.
Examples
Example 1
Input: Write table-driven tests for entity.NewUser() validation
Output:
func TestNewUser(t *testing.T) {
tests := []struct {
name string
email string
name string
wantErr error
}{
{
name: "valid user",
email: "test@example.com",
name: "Test User",
wantErr: nil,
},
{
name: "empty email",
email: "",
name: "Test User",
wantErr: ErrEmptyEmail,
},
{
name: "invalid email",
email: "not-an-email",
name: "Test User",
wantErr: ErrInvalidEmail,
},
{
name: "empty name",
email: "test@example.com",
name: "",
wantErr: ErrEmptyName,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
user, err := entity.NewUser(tt.email, tt.name)
if tt.wantErr != nil {
require.Error(t, err)
assert.ErrorIs(t, err, tt.wantErr)
assert.Nil(t, user)
return
}
require.NoError(t, err)
assert.NotNil(t, user)
assert.NotEqual(t, uuid.Nil, user.ID)
assert.Equal(t, tt.email, user.Email)
assert.Equal(t, tt.name, user.Name)
assert.False(t, user.CreatedAt.IsZero())
})
}
}
Pattern: t.Parallel() for isolation, require.NoError for fatal errors, assert for non-fatal checks.
Example 2
Input: Write integration test for user repository with testcontainers
Output:
See references/testcontainers-setup.md for complete testcontainers setup with PostgreSQL, migrations, and repository tests.
Example 3
Input: Write usecase test with mocked repository
Output:
See references/usecase-mocking.md for complete UseCase testing with gomock, setup functions, and type-safe mocks.
Test Execution Workflow
Commands
go test ./... -v # All tests
go test -race ./... # Race detection
go test -run TestXxx -v ./pkg/... # Specific test
go test -coverprofile=c.out ./... # Coverage
Analysis Process
- Run tests, capture output
- Identify failure pattern
- Check recent changes:
git diff - Trace error to root cause
- Provide specific fix
TDD Cycle
- RED: Write failing test first
- GREEN: Implement minimal solution to pass
- REFACTOR: Clean up while tests stay green
Common Fixes
- Race: Add mutex or channels
- Flaky: Replace
time.Sleepwith channels or sync primitives - Pollution: Add
t.Parallel(),t.Cleanup() - Timeout: Check for blocking operations, add context cancellation
References
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/go-testing-tdd-patterns-msh3utuf/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/go-testing-tdd-patterns-msh3utuf' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/go-testing-tdd-patterns-msh3utuf/download' --output '.skill-downloads/go-testing-tdd-patterns-msh3utuf/SKILL.md.part' && mv '.skill-downloads/go-testing-tdd-patterns-msh3utuf/SKILL.md.part' '.skill-downloads/go-testing-tdd-patterns-msh3utuf/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/go-testing-tdd-patterns-msh3utuf/SKILL.md' && test -s '.skill-downloads/go-testing-tdd-patterns-msh3utuf/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/go-test' && cp -R '.skill-downloads/go-testing-tdd-patterns-msh3utuf' '.claude/skills/go-test'Cursor
test -f '.skill-downloads/go-testing-tdd-patterns-msh3utuf/SKILL.md' && test -s '.skill-downloads/go-testing-tdd-patterns-msh3utuf/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/go-test' && cp -R '.skill-downloads/go-testing-tdd-patterns-msh3utuf' '.cursor/skills/go-test'Codex
test -f '.skill-downloads/go-testing-tdd-patterns-msh3utuf/SKILL.md' && test -s '.skill-downloads/go-testing-tdd-patterns-msh3utuf/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/go-test' && cp -R '.skill-downloads/go-testing-tdd-patterns-msh3utuf' '.agents/skills/go-test'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/go-testing-tdd-patterns-msh3utuf'openskills read 'go-testing-tdd-patterns-msh3utuf'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/go-testing-tdd-patterns-msh3utuf/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
ClickHouse Performance Comparison
Testing
Evaluate ClickHouse performance test results, check PR performance changes, compare with history, and assess whether a result is actionable.
Analyze CI Performance Reports
Testing
Analyze CI performance comparison reports for a ClickHouse PR. Cross-references master history to distinguish real regressions from flaky tests.
Santa Method
Testing
Multi-agent adversarial verification with two independent reviewers. Output is checked twice and iteratively fixed until both pass before shipping.