testcontainers-shared-fixture

Community

Share one MongoDB container across xUnit

Authormpaulosky
Version1.0.0
Installs0

System Documentation

What problem does it solve?

Many xUnit integration test classes each start their own MongoDbContainer which multiplies startup time and inflates CI run durations; this pattern reduces repeated container startups by sharing a single Testcontainers MongoDB instance per xUnit collection while preserving test isolation.

Core Features & Use Cases

  • Shared Fixture Lifecycle: Use a MongoDbFixture implementing IAsyncLifetime to start and stop one MongoDbContainer per xUnit collection.
  • Collection-level Parallelism: Define ICollectionFixture-based collections so related test classes share a container while different collections run in parallel.
  • Per-test Isolation: Create unique databases per test method using GUID-based names to maintain isolation without per-class containers.
  • CI Performance: Configure xunit.runner.json to enable collection-level parallelization and dramatically reduce total test startup time.
  • Practical Use Case: Ideal for .NET integration tests that use Testcontainers and MongoDB where dozens of test classes previously created slow sequential containers.

Quick Start

Convert per-class MongoDbContainer setups into a single MongoDbFixture shared via ICollectionFixture and enable parallelizeTestCollections in xunit.runner.json to cut container startup overhead.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: testcontainers-shared-fixture
Download link: https://github.com/mpaulosky/dotfiles/archive/main.zip#testcontainers-shared-fixture

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.