Agent skill · software engineering · aaronontheweb
testcontainers-integration-tests
Write integration tests using TestContainers for .NET with xUnit. Covers infrastructure testing with real databases, message queues, and caches in Docker containers instead of mocks.
Why this skill is useful
Provides specific patterns and examples for using TestContainers with real databases in .NET integration tests, which the AI wouldn't reliably generate on its own.
What it needs
Requires docker, dotnet-sdk installed locally. About 3k tokens when loaded. Last updated 2026-07-03. 1,095 stars on the source repository.
What this skill does
Integration Testing with TestContainers When to Use This Skill Use this skill when: Writing integration tests that need real infrastructure (databases, caches, message queues) Testing data access layers against actual databases Verifying message queue integrations Testing Redis caching behavior Avoiding mocks for infrastructure components Ensuring tests work against production-like environments Testing database migrations and schema changes Reference Files database-patterns.md: SQL Server, PostgreSQL, and migration testing examples infrastructure-patterns.md: Redis, RabbitMQ, multi-container networks, container reuse, and Respawn Core Principles 1. Real Infrastructure Over Mocks - Use actual databases/services in containers, not mocks 2. Test Isolation - Each test gets fresh containers or fresh data 3. Automatic Cleanup - TestContainers handles container lifecycle and cleanup 4. Fast Startup - Reuse containers across tests in the same class when appropriate 5. CI/CD Compatible - Works seamlessly in Docker-enabled CI environments 6. Port Randomization - Containers use random ports to avoid conflicts Why TestContainers Over Mocks? The Problem with Mocking Infrastructure Problems: doesn't test actual SQL queries, misses constraints/indexes, gives false confidence, doesn't catch SQL syntax errors. Better: TestContainers with Real Database See database-patterns.md for complete SQL Server, PostgreSQL, and migration testing examples. See infrastructure-patterns.md for Redis, RabbitMQ, multi-container networks, container reuse, and Respawn database reset patterns. Required NuGet Packages Best Practices 1. Always Use IAsyncLifetime - Proper async setup and teardown 2. Wait for Port Availability - Use WaitStrategy to ensure containers are ready 3. Use Random Ports - Let TestContainers assign ports automatically 4. Clean Data Between Tests - Either use fresh containers or truncate tables 5. Reuse Containers When Possible - Faster than creating new ones for each test 6. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills aaronontheweb/testcontainers