Skip to main content
net8.0net9.0

Experimental package. Test fakes for integration testing

Published
Oct 8, 2024
2y ago
Total Downloads
125.2K
125,194

Install

dotnet add package Microsoft.AspNetCore.Testing --version 9.0.0-preview.9.24507.7
ProductVersions
.NET
net8.0net9.0

README

Microsoft.AspNetCore.Testing

This package provides test fakes for integration testing of ASP.NET Core applications.

In particular:

  • IWebHostBuilder extensions to setup the test web app.
  • IHost extensions to access that test web app.

Install the package

From the command-line:

dotnet add package Microsoft.AspNetCore.Testing

Or directly in the C# project file:

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

Usage Example

Creating a Test Web App

The IWebHostBuilder extensions can help set up a host for testing.

using var host = await FakeHost.CreateBuilder()
    .ConfigureWebHost(webHost => webHost.UseFakeStartup().ListenHttpOnAnyPort())
    .StartAsync();

Accessing the test Web App

The IHost extensions can help access the test host that was created above.

using var client = host.CreateClient();

var response = await client.GetAsync("/");

Feedback & Contributing

We welcome feedback and contributions in our GitHub repo.

Changes from Previous Version

No structural changes between v9.0.0-preview.8.24460.1 and v9.0.0-preview.9.24507.7.

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 2 target frameworks; confirm the exact target used by your application.

Related Guides & Workflows

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