Testcontainers in CI: Integration Tests Against Real Postgres and Redis, No Mocks and No Shared Environments
A practical guide to replacing mocks with real dependencies in your tests: why a mock only confirms your own assumptions, how to spin up ephemeral Postgres and Redis with Testcontainers, balancing one container per session against clean state per test (savepoint rollback vs TRUNCATE RESTART IDENTITY CASCADE), running your real Alembic migrations instead of create_all(), wait strategies that kill flaky tests, networks and aliases across multiple containers, a GitHub Actions pipeline with image pre-pulling, how Ryuk works and when to disable it, container reuse for local runs only, an equivalent TypeScript example, and a checklist of the mistakes that cost the most time.
Verificando acceso...