Testcontainers
Patterns for real-infrastructure .NET integration tests using Testcontainers instead of mocks.
- CCM score
- 43 of 100
- skills.sh installs
- 573
- GitHub stars
- 94
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers spinning up real databases, caches, and message brokers in Docker containers for .NET tests
- Includes SQL Server, PostgreSQL, and MySQL examples, plus Redis, RabbitMQ, and Kafka patterns in reference files
- Enforces test isolation with fresh containers or truncated tables, random port mapping, and disposal in
DisposeAsync - Designed for .NET teams that need data access and migration tests to exercise real SQL behavior
Install
$ npx -y skills add wshaddix/dotnet-skills --skill testcontainers -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
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
Core Principles
- Real Infrastructure Over Mocks - Use actual databases/services in containers, not mocks
- Test Isolation - Each test gets fresh containers or fresh data
- Automatic Cleanup - TestContainers handles container lifecycle and cleanup
- Fast Startup - Reuse containers across tests in the same class when appropriate
- CI/CD Compatible - Works seamlessly in Docker-enabled CI environments
- Port Randomization - Containers use random ports to avoid conflicts
Why TestContainers Over Mocks?
Problems with Mocking Infrastructure
// BAD: Mocking a database
public class OrderRepositoryTests
{
private readonly Mock<IDbConnection> _mockDb = new();
Details
- Repository
- github.com/wshaddix/dotnet-skills
- Categories
- Testing & QA, .NET & C#, Databases
- First seen
- Jun 3, 2026
More from wshaddix/dotnet-skills
All 13- Microsoft Extensions Dependency Injection557
- Logging Observability551
- Validation Patterns546
- Project Structure542
- Dotnet Domain Modeling539
- Serialization532
- Microsoft Extensions Configuration529
- Package Management519
- Dotnet Testing Strategy625
- Dotnet Xunit625
- Modern Csharp Coding Standards596
- Csharp Wolverinefx576
Similar to Testcontainers
More Testing & QAcsharp-testingSkillaffaan-m/ecc10.7K installsC# and .NET testing patterns using xUnit, FluentAssertions, mocking, and integration test setups.
aspire-integration-testingSkillaaronontheweb/dotnet-skills545 installsIntegration test patterns for .NET Aspire apps using xUnit fixtures, real dependencies, and runtime endpoint discovery.
integration-testingSkillaj-geddes/useful-ai-prompts564 installsDesign integration tests that verify real API, database, and service interactions without mocking the data layer.
bdd-dotnetPluginnesbo/dotnet-claude-code-skills56 starsBDD-style unit testing patterns for domain handlers with in-memory database, TestDataBuilder pattern, fluent builders, and fake implementations - no mocking fra