golang-testcontainers
Installation
SKILL.md
Go Integration Testing with Testcontainers
When to Use This Skill
- Writing integration tests that need real infrastructure (databases, caches, message queues)
- Testing data access layers against actual databases instead of mocks
- Verifying message queue or cache integrations
- Testing database migrations and schema changes
- Ensuring tests work against production-like environments in CI/CD
Core Principles
- Real Infrastructure Over Mocks - Use actual databases/services in containers, not mocks
- Test Isolation - Each test gets fresh containers or clean data via snapshots
- Automatic Cleanup -
testcontainers.CleanupContainer(t, ctr)handles lifecycle - Idiomatic Go - Table-driven tests,
t.Helper(),t.Cleanup(), subtests - Context Propagation - Pass
context.Contextto all container operations - Port Randomization - Containers use random ports to avoid conflicts