Soenneker.TestHosts.Integration
4.0.245
Prefix Reserved
dotnet add package Soenneker.TestHosts.Integration --version 4.0.245
NuGet\Install-Package Soenneker.TestHosts.Integration -Version 4.0.245
<PackageReference Include="Soenneker.TestHosts.Integration" Version="4.0.245" />
<PackageVersion Include="Soenneker.TestHosts.Integration" Version="4.0.245" />
<PackageReference Include="Soenneker.TestHosts.Integration" />
paket add Soenneker.TestHosts.Integration --version 4.0.245
#r "nuget: Soenneker.TestHosts.Integration, 4.0.245"
#:package Soenneker.TestHosts.Integration@4.0.245
#addin nuget:?package=Soenneker.TestHosts.Integration&version=4.0.245
#tool nuget:?package=Soenneker.TestHosts.Integration&version=4.0.245
Soenneker.TestHosts.Integration
A TUnit-compatible host for lazily creating and sharing configured ASP.NET Core WebApplicationFactory instances.
Installation
dotnet add package Soenneker.TestHosts.Integration
Define the shared host
using Soenneker.TestHosts.Integration;
public sealed class Host : IntegrationTestHost
{
public override Task InitializeAsync()
{
RegisterFactory<Api.Program>("Api");
return base.InitializeAsync();
}
}
Call RegisterFactory<TEntryPoint> before requesting that type. Registration is lazy: the application is not built until the factory's Value is first used. Registering the same entry-point type again has no effect.
Use it from TUnit
using TUnit.Core;
[ClassDataSource<Host>(Shared = SharedType.PerTestSession)]
public sealed class HealthTests
{
private readonly Host _host;
public HealthTests(Host host)
{
_host = host;
}
[Test]
public async Task Health_is_available()
{
var factory = _host.GetFactory<Api.Program>().Value;
using HttpClient client = factory.CreateClient();
using HttpResponseMessage response = await client.GetAsync("/health");
await Assert.That(response.IsSuccessStatusCode).IsTrue();
}
}
TUnit initializes the host's Bogus Faker and AutoFaker and disposes every factory that was actually created. The host itself owns those factories; tests should dispose clients and responses, not the shared factory.
Test-host configuration
For each registered project name, the host requires an appsettings.json at the path returned by IntegrationTestHost.GetAppSettingsPath(projectName). That path is <parent of AppContext.BaseDirectory>/<projectName>/appsettings.json; missing files fail factory creation.
Each factory also installs the test authentication scheme, JWT utilities, loopback-address middleware, and a Serilog sink for the active TUnit context. The loopback rewrite is test-only and should not be copied into production startup.
GetFactory<TEntryPoint>() returns the registered Lazy<WebApplicationFactory<TEntryPoint>> and throws when that entry point was never registered.
| 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
- Microsoft.AspNetCore.Mvc.Testing (>= 10.0.13)
- Serilog.AspNetCore (>= 10.0.0)
- Serilog.Sinks.Async (>= 2.1.0)
- Soenneker.Enums.DeployEnvironment (>= 4.0.260)
- Soenneker.Extensions.ValueTask (>= 4.0.133)
- Soenneker.Serilog.Sinks.TUnit (>= 4.0.151)
- Soenneker.StartupFilters.IntegrationTests (>= 4.0.142)
- Soenneker.Utils.AutoBogus (>= 4.0.989)
- Soenneker.Utils.Test.AuthHandler (>= 4.0.386)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.TestHosts.Integration:
| Package | Downloads |
|---|---|
|
Soenneker.Tests.Integration
A TUnit base class for integration tests that use a shared WebApplicationFactory host. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.245 | 0 | 10/15/2026 |
| 4.0.244 | 0 | 10/15/2026 |
| 4.0.241 | 19 | 10/14/2026 |
| 4.0.239 | 36 | 10/14/2026 |
| 4.0.238 | 63 | 10/14/2026 |
| 4.0.237 | 52 | 10/14/2026 |
| 4.0.231 | 87 | 10/13/2026 |
| 4.0.230 | 73 | 10/13/2026 |
| 4.0.227 | 112 | 10/12/2026 |
| 4.0.226 | 83 | 10/12/2026 |
| 4.0.225 | 85 | 10/12/2026 |
| 4.0.224 | 81 | 10/11/2026 |
| 4.0.223 | 89 | 10/11/2026 |
| 4.0.222 | 83 | 10/11/2026 |
| 4.0.221 | 161 | 10/9/2026 |
| 4.0.220 | 108 | 10/8/2026 |
| 4.0.219 | 99 | 10/6/2026 |
| 4.0.218 | 121 | 10/3/2026 |
| 4.0.217 | 118 | 10/1/2026 |
| 4.0.216 | 115 | 9/30/2026 |
Updated NuGet packages