testcontainers-dotnet

Orchestrate Testcontainers modules to start disposable Docker dependencies for .NET integration tests.

Updated Jan 29, 2024
One-click install
npx skills add https://github.com/riandeoliveira/aspnet-template --skill testcontainers-dotnet-riandeoliveira
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testcontainers-dotnet
Source: https://github.com/riandeoliveira/aspnet-template/tree/main/.claude/skills/testcontainers-dotnet
Command: npx skills add https://github.com/riandeoliveira/aspnet-template --skill testcontainers-dotnet-riandeoliveira

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you avoid flaky integration tests by giving you a repeatable way to start real Docker-backed dependencies during your .NET test runs.

Core Features & Use Cases

  • Use pre-configured Testcontainers modules to spin up common services with sensible defaults.
  • Create and manage containers in .NET tests using the module/container builders, including networking, environment variables, and mapped ports.
  • Ensure reliability with explicit readiness (wait) strategies so your tests only run after the service is actually ready.
  • Use Case: You need integration tests that validate your application against PostgreSQL by running a real query, without manually managing a database instance or risking inconsistent CI timing.

Quick Start

Add Testcontainers for the PostgreSQL module and your PostgreSQL client library, then run a simple smoke test that starts the container, connects using the generated connection string, executes SELECT 1, and disposes the container.

Frequently Asked Questions about testcontainers-dotnet

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

FAQPage Schema
How do I run reliable .NET integration tests using Docker containers?

You run reliable .NET integration tests by orchestrating Testcontainers modules to start disposable Docker dependencies on demand, applying mandatory explicit wait strategies so tests execute only after services are fully ready.

Why are my .NET integration tests flaky when starting Docker dependencies?

.NET integration tests become flaky without explicit readiness wait strategies, because test execution begins before the Docker container service is actually prepared to accept database or network connections.

How do I start a PostgreSQL database in xUnit or NUnit for integration testing?

You start PostgreSQL in xUnit or NUnit for integration testing by using pre-configured Testcontainers modules to spin up disposable database instances, connect via generated connection strings, and execute validation queries before disposal.

Does Testcontainers for .NET support parameterized testing across different container images?

Testcontainers for .NET supports parameterized testing across container images and configurations, allowing you to validate application behavior against multiple Docker-backed service versions during test runs.

What is the best way to ensure deterministic cleanup of Docker containers in .NET CI pipelines?

Deterministic cleanup of Docker containers in .NET CI pipelines is ensured by orchestrating Testcontainers modules that manage container lifecycles and automatically dispose of dependencies after tests complete.