A test fixture for xUnit V3 supporting reusable containers.
This is a drop-in replacement for TestContainers.XunitV3.
dotnet add package Reusable.XunitV3.TestContainershttps://www.nuget.org/packages/Reusable.XunitV3.TestContainers/
This library has the same functionality as TestContainers.XunitV3 but also supports test runner parallelism when using reusable containers.
To enable the reuse feature, set the TESTCONTAINERS_REUSE_ENABLE environment variable to true or override the Reuse property of ContainerFixture. The fixture will use the Docker API to guarantee idempotency when the reusable container is created, i.e. only one container with the current set of labels will be created no matter how many test runners start the fixture at the same time. It does so by using the reuse hash as the container name.
You can read more here: testcontainers/testcontainers-dotnet#1482
public sealed class HelloWorldContainerFixture(IMessageSink sink)
: ContainerFixture<HelloWorldContainerBuilder, HelloWorldContainer>(sink)
{
protected override bool Reuse => true;
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.