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

  1. Real Infrastructure Over Mocks - Use actual databases/services in containers, not mocks
  2. Test Isolation - Each test gets fresh containers or clean data via snapshots
  3. Automatic Cleanup - testcontainers.CleanupContainer(t, ctr) handles lifecycle
  4. Idiomatic Go - Table-driven tests, t.Helper(), t.Cleanup(), subtests
  5. Context Propagation - Pass context.Context to all container operations
  6. Port Randomization - Containers use random ports to avoid conflicts
Related skills

More from baotoq/agent-skills

Installs
8
GitHub Stars
1
First Seen
Feb 16, 2026