ProtoTest.Testcontainers
1.1.1
dotnet add package ProtoTest.Testcontainers --version 1.1.1
NuGet\Install-Package ProtoTest.Testcontainers -Version 1.1.1
<PackageReference Include="ProtoTest.Testcontainers" Version="1.1.1" />
<PackageVersion Include="ProtoTest.Testcontainers" Version="1.1.1" />
<PackageReference Include="ProtoTest.Testcontainers" />
paket add ProtoTest.Testcontainers --version 1.1.1
#r "nuget: ProtoTest.Testcontainers, 1.1.1"
#:package ProtoTest.Testcontainers@1.1.1
#addin nuget:?package=ProtoTest.Testcontainers&version=1.1.1
#tool nuget:?package=ProtoTest.Testcontainers&version=1.1.1
ProtoTest.Testcontainers
Shared container-resource support used by ProtoTest's Testcontainers packages, and the application container for an application under test.
Use it directly to start an application image with the run, or when building another run-scoped container integration.
ProtoContainerResource<TContainer> handles start-once and release-once behaviour. Register a resource as a target's UseContainer(...) provider when the host should start it and expose values such as a connection string. The technology packages (ProtoTest.Sql.Testcontainers, ProtoTest.Messaging.RabbitMq.Testcontainers, ProtoTest.Devices.Mqtt.Testcontainers) build on this contract: run-scoped start-once, TryStart reporting instead of throwing, and UseContainer(...) chain providers.
ApplicationContainer starts an application image as run infrastructure and publishes the mapped address as ProtoTest:Applications:{application}:BaseUrl, so the application's REST clients, browser sessions and the readiness probe resolve that one container:
var api = ApplicationContainer.Container("Api", "mcr.microsoft.com/dotnet/samples:aspnetapp", port: 8080);
builder
.AddInfrastructure(
api.Application,
chain => chain
.UseConfigured() // a configured key skips the container
.UseContainer(api),
api.BaseUrlKey)
.AddHttpReadiness(api.Application, "/")
.AddApplication(api.Application, app => app
.AddRest(rest => rest.AddClient(api.Application))
.AddWeb());
The published address is http://{hostname}:{mapped port}; the default readiness check waits for the declared port to accept a connection, and the configure callback adds container build options or a Testcontainers wait strategy. A machine without a container runtime reports the reason through TryStart, so the suite can skip instead of failing.
UseContainer(PostgresDatabase.Container()) adds the container behind the Docker probe (DockerProbe.IsAvailable()), so a configured or AppHost provider earlier in the chain wins and the container starts only when the environment cannot serve the target.
The package does not depend on a specific Testcontainers module. Technology packages supply their own module container (for example PostgresDatabase); ApplicationContainer builds on the Testcontainers core library.
Limits
- The image and its readiness belong to the suite.
ApplicationContainerknows only the image and the port it listens on - not the application's health endpoint, environment or protocol. AddAddHttpReadiness(application, path)for an HTTP-level wait. - One scheme:
http. The mapped address is published ashttp://…; an image that only serves HTTPS is not covered - point the application at that environment throughProtoTest:Applications:{application}:BaseUrlinstead. UseContainerfollows the Docker probe, not the piece's own condition. A provider earlier in the chain (a configured key, an AppHost resource) wins without probing, and a machine whose daemon does not answer skips the container withDocker is availableas the recorded reason.
Learn more
| Product | Versions 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. |
-
net10.0
- Docker.DotNet.Enhanced (>= 4.3.3)
- ProtoTest.Core (>= 1.1.1)
- Testcontainers (>= 4.15.0)
-
net8.0
- Docker.DotNet.Enhanced (>= 4.3.3)
- ProtoTest.Core (>= 1.1.1)
- Testcontainers (>= 4.15.0)
-
net9.0
- Docker.DotNet.Enhanced (>= 4.3.3)
- ProtoTest.Core (>= 1.1.1)
- Testcontainers (>= 4.15.0)
NuGet packages (3)
Showing the top 3 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. |
|
|
ProtoTest.Devices.Mqtt.Testcontainers
A Mosquitto MQTT broker container owned as a run-scoped resource for ProtoTest.Devices.Mqtt. |
GitHub repositories
This package is not used by any popular GitHub repositories.