testcontainers-dotnet

Configure Docker-based Testcontainers for .NET integration tests with xUnit v3.

5|1|Updated Nov 21, 2025
One-click install
npx skills add https://github.com/ANcpLua/ancplua-claude-plugins --skill testcontainers-dotnet
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testcontainers-dotnet
Source: https://github.com/ANcpLua/ancplua-claude-plugins/tree/main/plugins/testcontainers-dotnet/skills/testcontainers-dotnet
Command: npx skills add https://github.com/ANcpLua/ancplua-claude-plugins --skill testcontainers-dotnet

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill guides .NET testing with Testcontainers, xUnit v3, Moq, and related tooling for reliable integration tests.

Core Features & Use Cases

  • Container fixtures: Use Testcontainers for PostgreSQL, RabbitMQ, Elasticsearch, MinIO.
  • Sealed wrappers: Techniques for mocking sealed clients.
  • Test patterns: IAsyncLifetime, ClassFixture, Theory, Handler extraction.

Quick Start

Follow the examples in the Examples folder to run integration tests with dotnet test.

Frequently Asked Questions about testcontainers-dotnet

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

FAQPage Schema
How do I write integration tests with Docker containers in .NET?

Integration tests with Docker containers use Testcontainers to spin up isolated services like PostgreSQL or RabbitMQ during test execution. Testcontainers manages container lifecycle automatically, letting you test against real dependencies without manual setup. This approach ensures tests are reproducible and don't interfere with each other.

Can I use Testcontainers with xUnit v3 and the Microsoft Testing Platform?

Yes. Testcontainers integrates with xUnit v3 through IAsyncLifetime, ClassFixture, and AssemblyFixture patterns, fully compatible with the Microsoft Testing Platform. This combination provides reliable container coordination across test classes and assemblies with native async support.

How do I mock sealed client types in .NET tests?

Sealed client wrappers let you abstract sealed types behind testable interfaces. Combined with Moq patterns like MockRepository and handler extraction, you can inject fake implementations during tests without modifying external library code.

What containerized services does Testcontainers support for .NET tests?

Testcontainers for .NET supports PostgreSQL, RabbitMQ, Elasticsearch, and MinIO as pre-built fixtures. Each container runs in isolation and shuts down automatically after tests complete, ensuring clean test environments and preventing resource leaks.

Do I need Docker installed to run .NET integration tests with Testcontainers?

Yes. Testcontainers requires Docker access to spawn and manage containers. You must have Docker installed and running on your development machine or CI/CD environment before executing integration tests.

How can I collect code coverage from tests using Testcontainers and xUnit v3?

The Microsoft Testing Platform provides native code coverage collection that works alongside Testcontainers and xUnit v3. Configure coverage collection in your test project, and metrics are gathered during test execution without additional tooling.