x-testcontainers-go

Standardize Go integration tests with testcontainers-go modules for external services.

2|Updated Apr 12, 2026
One-click install
npx skills add https://github.com/pure-golang/level85 --skill x-testcontainers-go
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: x-testcontainers-go
Source: https://github.com/pure-golang/level85/tree/main/.agents/skills/x-testcontainers-go
Command: npx skills add https://github.com/pure-golang/level85 --skill x-testcontainers-go

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the pain of flaky and slow integration tests by providing a consistent way to start real external dependencies locally using testcontainers-go, then automatically stop them after the test run.

Core Features & Use Cases

  • Use ready-made containers for PostgreSQL, RabbitMQ, Redis, Kafka, and MongoDB via testcontainers-go modules instead of building containers from scratch.
  • Standardize integration test bootstrap for both regular Go tests/suites and BDD godog tests so they share the same container lifecycle.
  • Enforce correctness and cleanup using context timeouts and tb.Cleanup to guarantee container termination, reducing resource leaks and nondeterminism.
  • Handle special cases responsibly by only using GenericContainer/manual setup when modules don’t cover the needed contract, with a short comment explaining why.

Quick Start

Update your integration test to start PostgreSQL (or another service) via the corresponding testcontainers-go module, wrap startup in context.WithTimeout, and register termination with tb.Cleanup so the container stops automatically after the test.

Frequently Asked Questions about x-testcontainers-go

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

FAQPage Schema
How do I run integration tests in Go with real databases without leaving orphaned Docker containers?

Use testcontainers-go modules to bootstrap real services like PostgreSQL and Redis, then register automatic cleanup with tb.Cleanup and context-scoped timeouts to guarantee container termination after tests finish.

Does testcontainers-go work with godog BDD scenarios for testing external brokers?

Yes, testcontainers-go integrates with godog BDD tests by sharing the same deterministic container startup lifecycle and automatic cleanup mechanisms used in standard Go test suites for brokers like RabbitMQ and Kafka.

What is the best way to start PostgreSQL and Kafka containers deterministically in Go tests?

The best way is using ready-made testcontainers-go modules for PostgreSQL and Kafka, wrapping startup in context.WithTimeout to enforce bounded execution, and wiring tb.Cleanup to stop containers reliably.

When should I use GenericContainer instead of a testcontainers-go module for my integration tests?

Use GenericContainer manually only when testcontainers-go modules do not cover your needed service contract, and you must provide explicit justification in a short comment explaining why the manual setup is necessary.

Why are my integration tests flaky when bootstrapping external services locally in Go?

Integration tests become flaky without deterministic container startup and guaranteed cleanup, which you can fix by applying testcontainers-go modules with context timeouts and tb.Cleanup to terminate containers reliably.

Can I test MinIO and MongoDB containers safely using testcontainers-go in Go?

Yes, testcontainers-go provides ready-made container modules for MinIO/S3 and MongoDB that safely start real services locally and automatically stop them using context-scoped timeouts and tb.Cleanup termination wiring.