ProtoTest.Testcontainers 1.0.1

dotnet add package ProtoTest.Testcontainers --version 1.0.1
                    
NuGet\Install-Package ProtoTest.Testcontainers -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ProtoTest.Testcontainers" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ProtoTest.Testcontainers" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ProtoTest.Testcontainers" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ProtoTest.Testcontainers --version 1.0.1
                    
#r "nuget: ProtoTest.Testcontainers, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ProtoTest.Testcontainers@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ProtoTest.Testcontainers&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ProtoTest.Testcontainers&version=1.0.1
                    
Install as a Cake Tool

ProtoTest.Testcontainers

The ProtoContainerResource<TContainer> base for run-scoped containers: start-once, release-once and TryStart, with no container-library dependency of its own.

dotnet add package ProtoTest.Testcontainers

Technology packages build on it — ProtoTest.Sql.Testcontainers and ProtoTest.Messaging.RabbitMq.Testcontainers — each keeping its own Testcontainers module dependency.

Quick start

public sealed class SearchIndexContainer : ProtoContainerResource<PostgreSqlContainer>
{
    public SearchIndexContainer() : base(
        () => new PostgreSqlBuilder("postgres:16-alpine").Build(),
        (container, cancellationToken) => container.StartAsync(cancellationToken),
        container => container.GetConnectionString())
    {
    }

    public override string Id => "search:postgres";
    public override string Kind => "search";
    public override string Description => "PostgreSQL search index";
}

// The host starts it before the run and fills the key for tests and applications alike.
builder.AddInfrastructure(new SearchIndexContainer(), "Search:Postgres:ConnectionString");

What it adds

  • Run-scoped resourceScope is ProtoResourceScope.Run; ConnectionString is empty until the container starts and IsStarted reports the state.
  • Start semantics — concurrent callers await one cached start task, a failed start stays retryable, and StartAsync after release throws ObjectDisposedException.
  • Fixture fallbackTryStartContainer starts a candidate synchronously and returns "{ExceptionType}: {message}" instead of throwing, so a fixture can fall back or skip.
  • Registration contractAddInfrastructure owns and starts the resource; AddResource alone only registers it for release and starts nothing.

A container runtime is required at host start and there is no built-in skip; a missing runtime fails the run before any test-level skip condition is evaluated.

Learn more

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on ProtoTest.Testcontainers:

Package Downloads
ProtoTest.Messaging.RabbitMq.Testcontainers

A RabbitMQ container owned as a run-scoped resource for ProtoTest.Messaging.RabbitMq.

ProtoTest.Sql.Testcontainers

A database container owned as a run-scoped resource for ProtoTest.Sql.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 83 9/20/2026
1.0.0 87 9/20/2026