Sylin.Koan.Testing.Containers
0.20.4
dotnet add package Sylin.Koan.Testing.Containers --version 0.20.4
NuGet\Install-Package Sylin.Koan.Testing.Containers -Version 0.20.4
<PackageReference Include="Sylin.Koan.Testing.Containers" Version="0.20.4" />
<PackageVersion Include="Sylin.Koan.Testing.Containers" Version="0.20.4" />
<PackageReference Include="Sylin.Koan.Testing.Containers" />
paket add Sylin.Koan.Testing.Containers --version 0.20.4
#r "nuget: Sylin.Koan.Testing.Containers, 0.20.4"
#:package Sylin.Koan.Testing.Containers@0.20.4
#addin nuget:?package=Sylin.Koan.Testing.Containers&version=0.20.4
#tool nuget:?package=Sylin.Koan.Testing.Containers&version=0.20.4
Sylin.Koan.Testing.Containers
Use this package for xUnit v3 integration specs that must exercise a Koan data adapter against its
real backing store. It supplies shared Testcontainers fixtures, Docker-free fixtures for the
in-memory/file adapters, and KoanDataSpec<TFixture> for the common compiled-host workflow.
Install
dotnet add package Sylin.Koan.Testing.Containers
Choose it when
- the behavior depends on real
AddKoan()discovery or hosted-service startup; - an adapter needs a reusable PostgreSQL, MongoDB, Redis, SQL Server, or Couchbase container;
- a Docker-free data spec should use the same fixture and host grammar as container-backed suites;
- each test should receive a fresh host while sharing the expensive backing-store fixture.
Do not choose it for pure unit tests or for application-level Entity conformance. Use
Koan.Testing.Hosting for a standalone compiled-composition host and Koan.Testing for the application
conformance batteries.
Configure the test assembly
Use xUnit v3, share one fixture per engine assembly, and serialize tests that boot KoanDataSpec
hosts. Each host owns the process-default AppHost binding for its lifetime; KoanDataSpec does not
make concurrent test classes flow-isolated.
using Koan.Testing.Containers;
using Xunit;
[assembly: CollectionBehavior(DisableTestParallelization = true)]
[assembly: AssemblyFixture(typeof(PostgresFixture))]
Meaningful result: write a data spec
public sealed class TodoSpec(PostgresFixture fixture, ITestOutputHelper output)
: KoanDataSpec<PostgresFixture>(fixture, output)
{
[Fact]
public async Task Saves_and_reads_a_todo()
{
RequireBackingStore();
await using var host = await BootAsync();
using var partition = Lease(NewPartition("roundtrip"));
var saved = await new Todo { Title = "Ship" }.Save();
(await Todo.Get(saved.Id)).Should().NotBeNull();
}
}
RequireBackingStore()fails with the fixture's diagnostic reason when setup did not produce a usable store. Optional local runs can select a Docker-free fixture; required native admission never treats missing infrastructure as evidence.BootAsync()starts a realKoanIntegrationHostwithAddKoan()and returns an async-disposableBoundHost.BootAsync(configure)adds test services afterAddKoan().- The settings overload merges per-test settings over the fixture defaults.
NewPartition()andLease()isolate data inside a shared backing store.- Disposing
BoundHoststops the host; Koan's generic-host binder releases its owner-checked ambient binding.
Included fixtures
PostgresFixture, MongoFixture, RedisFixture, SqlServerFixture, and CouchbaseFixture use
Testcontainers. InMemoryFixture, JsonFixture, and SqliteFixture provide the same contract
without Docker. CockroachFixture is available for CockroachDB-specific suites.
An explicit Koan_<ENGINE>__CONNECTION_STRING environment variable selects a pre-running service;
otherwise container fixtures use Testcontainers' normal runtime discovery. A bad endpoint, unavailable
runtime, image/start failure, or stop failure remains a failed test with its original diagnostic.
Limits
- Tests within one process must serialize host boots unless they establish their own explicit
AppHost.PushScopearound the complete operation flow. - Partition isolation protects data; it does not make process-default host selection parallel-safe.
- Container-start and teardown failures fail the fixture. Use an explicit Docker-free fixture when the intended test contract does not require native infrastructure.
See TECHNICAL.md for lifecycle and ownership details and
docs/guides/testing-your-app.md for the broader testing
surface.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- Sylin.Koan.Core (>= 0.20.7 && < 0.21.0)
- Sylin.Koan.Data.Core (>= 0.21.0 && < 0.22.0)
- Sylin.Koan.Testing.Hosting (>= 0.20.4 && < 0.21.0)
- Testcontainers.Couchbase (>= 4.13.0)
- Testcontainers.MongoDb (>= 4.13.0)
- Testcontainers.MsSql (>= 4.13.0)
- Testcontainers.PostgreSql (>= 4.13.0)
- Testcontainers.Redis (>= 4.13.0)
- xunit.v3.assert (>= 3.2.2)
- xunit.v3.extensibility.core (>= 3.2.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.