Microsoft.AspNetCore.TestHost
10.0.8
Prefix Reserved
See the version list below for details.
dotnet add package Microsoft.AspNetCore.TestHost --version 10.0.8
NuGet\Install-Package Microsoft.AspNetCore.TestHost -Version 10.0.8
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="10.0.8" />
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="10.0.8" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" />
paket add Microsoft.AspNetCore.TestHost --version 10.0.8
#r "nuget: Microsoft.AspNetCore.TestHost, 10.0.8"
#:package Microsoft.AspNetCore.TestHost@10.0.8
#addin nuget:?package=Microsoft.AspNetCore.TestHost&version=10.0.8
#tool nuget:?package=Microsoft.AspNetCore.TestHost&version=10.0.8
About
Microsoft.AspNetCore.TestHost provides an ASP.NET Core web server for testing middleware in isolation.
Key Features
- Instantiate an app pipeline containing only the components that you need to test
- Send custom requests to verify middleware behavior
How to Use
To use Microsoft.AspNetCore.TestHost, follow these steps:
Installation
dotnet add package Microsoft.AspNetCore.TestHost
Usage
To set up the TestServer, configure it in your test project. Here's an example:
[Fact]
public async Task MiddlewareTest_ReturnsNotFoundForRequest()
{
// Build and start a host that uses TestServer
using var host = await new HostBuilder()
.ConfigureWebHost(builder =>
{
builder.UseTestServer()
.ConfigureServices(services =>
{
// Add any required services that the middleware uses
services.AddMyServices();
})
.Configure(app =>
{
// Configure the processing pipeline to use the middleware
// for the test
app.UseMiddleware<MyMiddleware>();
});
})
.StartAsync();
var response = await host.GetTestClient().GetAsync("/");
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}
Main Types
The main types provided by this package are:
TestServer: AnIServerimplementation for executing testsTestServerOptions: Provides options for configuring aTestServer
Additional Documentation
For additional documentation and examples, refer to the official documentation for testing middleware in ASP.NET Core.
Feedback & Contributing
Microsoft.AspNetCore.TestHost is released as open-source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
| 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
- No dependencies.
NuGet packages (195)
Showing the top 5 NuGet packages that depend on Microsoft.AspNetCore.TestHost:
| Package | Downloads |
|---|---|
|
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications. This package was built from the source code at https://github.com/dotnet/dotnet/tree/4370ea16341331f045fa9b89cc46e03aed27195c |
|
|
Rystem.Test.XUnit
Rystem is a open-source framework to improve the System namespace in .Net |
|
|
MyTested.AspNetCore.Mvc.Abstractions
My Tested ASP.NET Core MVC common abstractions and interfaces. |
|
|
Reo.Core.IntegrationTesting
Package Description |
|
|
Acheve.TestHost
Achve.TestHost is a nuget package to improve TestServer experiences. For more information see http://github.com/Xabaril/Acheve.TestHost |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.0-preview.4.26230.115 | 4,166 | 5/12/2026 |
| 11.0.0-preview.3.26207.106 | 3,709 | 4/14/2026 |
| 11.0.0-preview.2.26159.112 | 4,866 | 3/10/2026 |
| 11.0.0-preview.1.26104.118 | 2,546 | 2/10/2026 |
| 10.0.8 | 1,221,220 | 5/12/2026 |
| 10.0.7 | 3,004,907 | 4/21/2026 |
| 10.0.6 | 969,372 | 4/14/2026 |
| 10.0.5 | 4,084,381 | 3/12/2026 |
| 10.0.4 | 463,022 | 3/10/2026 |
| 10.0.3 | 4,562,638 | 2/10/2026 |
| 9.0.16 | 110,755 | 5/12/2026 |
| 9.0.15 | 432,404 | 4/14/2026 |
| 9.0.14 | 548,364 | 3/10/2026 |
| 9.0.13 | 449,313 | 2/10/2026 |
| 9.0.12 | 618,664 | 1/13/2026 |
| 8.0.27 | 226,501 | 5/12/2026 |
| 8.0.26 | 658,898 | 4/14/2026 |
| 8.0.25 | 932,062 | 3/10/2026 |
| 8.0.24 | 902,701 | 2/10/2026 |
| 2.3.10 | 555 | 5/12/2026 |