Soenneker.TestHosts.Integration 11.0.261

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.TestHosts.Integration --version 11.0.261
                    
NuGet\Install-Package Soenneker.TestHosts.Integration -Version 11.0.261
                    
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="Soenneker.TestHosts.Integration" Version="11.0.261" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.TestHosts.Integration" Version="11.0.261" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.TestHosts.Integration" />
                    
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 Soenneker.TestHosts.Integration --version 11.0.261
                    
#r "nuget: Soenneker.TestHosts.Integration, 11.0.261"
                    
#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 Soenneker.TestHosts.Integration@11.0.261
                    
#: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=Soenneker.TestHosts.Integration&version=11.0.261
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.TestHosts.Integration&version=11.0.261
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

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 Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.271 0 11/10/2026
11.0.270 66 11/7/2026
11.0.269 61 11/7/2026
11.0.268 80 11/4/2026
11.0.267 76 11/3/2026
11.0.266 77 11/3/2026
11.0.265 80 11/3/2026
11.0.264 78 11/3/2026
11.0.263 75 11/3/2026
11.0.262 77 11/2/2026
11.0.261 62 11/2/2026
11.0.260 87 11/2/2026
11.0.259 92 10/29/2026
11.0.258 84 10/27/2026
11.0.257 67 10/27/2026
11.0.255 84 10/27/2026
11.0.254 80 10/26/2026
11.0.252 75 10/26/2026
11.0.251 75 10/26/2026
11.0.250 82 10/26/2026
Loading failed

Updated Soenneker.Utils.AutoBogus to 11.0.998