# testcontainers

A skill for .NET integration tests: spins up real databases, Redis and message brokers in Docker instead of mocks.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 565 installs · ★ 86
- Author: wshaddix
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/wshaddix/dotnet-skills/tree/HEAD/skills/testcontainers/SKILL.md
- Updated: 2026-02-27
- HTML: https://affpapa.org/en/nevibecode/skills/testcontainers

## What it does

This skill lays out Testcontainers patterns for .NET integration tests. Your tests talk to actual SQL Server, PostgreSQL, MySQL, Redis, RabbitMQ or Kafka instances, each in its own container. Containers get random ports, so parallel runs don't collide, and Testcontainers handles the lifecycle for you.

Inside are C# examples: a test class implements `IAsyncLifetime`, `InitializeAsync` starts the container and opens a connection, `DisposeAsync` tears everything down. It also covers the NuGet packages you need (`Testcontainers`, `xunit`, database drivers), readiness checks with `WaitStrategy`, migrations, and clearing data between tests. Reference files go deeper on database containers, message brokers, and advanced setups like networks and volumes.

Docker is required. No running daemon means containers never start and your tests fail during setup — worth checking before you wire this into CI. The sample connection strings and passwords sit right in the code, so move them to configuration for a real project.

## Requirements
- Works with: Docker

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill testcontainers -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/testcontainers/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/testcontainers/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill testcontainers -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/testcontainers/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill testcontainers -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/testcontainers/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install wshaddix/dotnet-skills testcontainers
```

2. **Manually: put the files in place**
- File: `.github/skills/testcontainers/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill testcontainers -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/wshaddix/dotnet-skills --path skills/testcontainers
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/testcontainers/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill testcontainers -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/wshaddix/dotnet-skills/tree/HEAD/skills/testcontainers/SKILL.md

## When to use it
- verify SQL queries and constraints against a real database instead of mocks
- spin up RabbitMQ or Kafka in a test and confirm messages arrive
- run migrations and schema changes before a deploy
- isolate tests from each other with separate containers
- check Redis caching behavior without hand-building an environment

## Example prompts
- write an integration test for the orders repository using Testcontainers and PostgreSQL
- add IAsyncLifetime to the test class and start a SQL Server container
- check that migrations apply cleanly to a fresh database in a container

## Similar
- [testcontainers-integration-tests](https://affpapa.org/en/nevibecode/skills/testcontainers-integration-tests.md) — skill · 544 installs
- [java-testcontainers](https://affpapa.org/en/nevibecode/skills/java-testcontainers.md) — skill · 1 install
- [testing](https://affpapa.org/en/nevibecode/skills/codewithmukesh-testing.md) — skill · 2800 installs
- [csharp-testing](https://affpapa.org/en/nevibecode/skills/csharp-testing.md) — skill · 4500 installs
- [tdd](https://affpapa.org/en/nevibecode/skills/codewithmukesh-tdd.md) — skill · 2800 installs
- [migrate-dotnet9-to-dotnet10](https://affpapa.org/en/nevibecode/skills/migrate-dotnet9-to-dotnet10.md) — skill · 3400 installs

From the same set: [wshaddix/dotnet-skills](https://affpapa.org/en/nevibecode/by/wshaddix/dotnet-skills.md) — 7 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
