Soenneker.TestHosts.Integration
11.0.269
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.TestHosts.Integration --version 11.0.269
NuGet\Install-Package Soenneker.TestHosts.Integration -Version 11.0.269
<PackageReference Include="Soenneker.TestHosts.Integration" Version="11.0.269" />
<PackageVersion Include="Soenneker.TestHosts.Integration" Version="11.0.269" />
<PackageReference Include="Soenneker.TestHosts.Integration" />
paket add Soenneker.TestHosts.Integration --version 11.0.269
#r "nuget: Soenneker.TestHosts.Integration, 11.0.269"
#:package Soenneker.TestHosts.Integration@11.0.269
#addin nuget:?package=Soenneker.TestHosts.Integration&version=11.0.269
#tool nuget:?package=Soenneker.TestHosts.Integration&version=11.0.269
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 | net11.0 is compatible. |
-
net11.0
- Microsoft.AspNetCore.Mvc.Testing (>= 11.0.0-rc.3.26522.148)
- Serilog.AspNetCore (>= 10.0.0)
- Serilog.Sinks.Async (>= 2.1.0)
- Soenneker.Enums.DeployEnvironment (>= 11.0.262)
- Soenneker.Serilog.Sinks.TUnit (>= 11.0.161)
- Soenneker.StartupFilters.IntegrationTests (>= 11.0.149)
- Soenneker.Utils.AutoBogus (>= 11.0.1002)
- Soenneker.Utils.Test.AuthHandler (>= 11.0.394)
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 |
|---|---|---|
| 11.0.294 | 0 | 11/19/2026 |
| 11.0.293 | 0 | 11/19/2026 |
| 11.0.292 | 9 | 11/18/2026 |
| 11.0.290 | 11 | 11/18/2026 |
| 11.0.288 | 45 | 11/18/2026 |
| 11.0.287 | 90 | 11/17/2026 |
| 11.0.286 | 90 | 11/17/2026 |
| 11.0.285 | 91 | 11/15/2026 |
| 11.0.284 | 93 | 11/15/2026 |
| 11.0.283 | 102 | 11/14/2026 |
| 11.0.282 | 110 | 11/13/2026 |
| 11.0.281 | 103 | 11/11/2026 |
| 11.0.279 | 109 | 11/11/2026 |
| 11.0.278 | 93 | 11/11/2026 |
| 11.0.277 | 95 | 11/11/2026 |
| 11.0.276 | 115 | 11/11/2026 |
| 11.0.274 | 106 | 11/11/2026 |
| 11.0.273 | 98 | 11/11/2026 |
| 11.0.272 | 128 | 11/11/2026 |
| 11.0.269 | 65 | 11/7/2026 |
Update dependency Soenneker.Serilog.Sinks.TUnit to 11.0.161 (#346)