Skip to main content
.NETFramework4.6.2net8.0net9.0

Experimental package. Tools for integration testing of apps built with Microsoft.Extensions.Hosting

Published
Mar 12, 2024
2y ago
Total Downloads
66.6K
66,585

Install

dotnet add package Microsoft.Extensions.Hosting.Testing --version 9.0.0-preview.2.24157.4
ProductVersions
.NET
net8.0net9.0
Other
.NETFramework4.6.2

README

Microsoft.Extensions.Hosting.Testing

Tools for integration testing of apps built with Microsoft.Extensions.Hosting.

Install the package

From the command-line:

dotnet add package Microsoft.Extensions.Hosting.Testing

Or directly in the C# project file:

<ItemGroup>
  <PackageReference Include="Microsoft.Extensions.Hosting.Testing" Version="[CURRENTVERSION]" />
</ItemGroup>

Usage Example

FakeHost

FakeHost enables creating an application host pre-configured for a unit test environment.

The host can be created using the following APIs:

public static IHostBuilder CreateBuilder()
public static IHostBuilder CreateBuilder(Action<FakeHostOptions> configure)
public static IHostBuilder CreateBuilder(FakeHostOptions options)

For example:

using var host = await FakeHost.CreateBuilder(options => { });
    .ConfigureServices(x =>
    {
        // ...
    })
    .StartAsync();

FakeHostingExtensions

FakeHostingExtensions is a collection of IHost and IHostBuilder extension methods for use within a unit test environment. These help collect logs as well as augment the host and app configurations.

Feedback & Contributing

For any feedback or contributions, please visit us in our GitHub repo.

Changes from Previous Version

No structural changes between v9.0.0-preview.1.24108.1 and v9.0.0-preview.2.24157.4.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 3 target frameworks; confirm the exact target used by your application.The published metadata declares 15 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.