Microsoft.AspNetCore.TestHost
10.0.0-preview.1.25120.3
Prefix Reserved
dotnet add package Microsoft.AspNetCore.TestHost --version 10.0.0-preview.1.25120.3
NuGet\Install-Package Microsoft.AspNetCore.TestHost -Version 10.0.0-preview.1.25120.3
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="10.0.0-preview.1.25120.3" />
paket add Microsoft.AspNetCore.TestHost --version 10.0.0-preview.1.25120.3
#r "nuget: Microsoft.AspNetCore.TestHost, 10.0.0-preview.1.25120.3"
// Install Microsoft.AspNetCore.TestHost as a Cake Addin #addin nuget:?package=Microsoft.AspNetCore.TestHost&version=10.0.0-preview.1.25120.3&prerelease // Install Microsoft.AspNetCore.TestHost as a Cake Tool #tool nuget:?package=Microsoft.AspNetCore.TestHost&version=10.0.0-preview.1.25120.3&prerelease
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
: AnIServer
implementation 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
- No dependencies.
NuGet packages (180)
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/aspnetcore/tree/b225d30209cf027c80b741d04efe1c54f2431b3c |
|
Rystem.Test.XUnit
Rystem is a open-source framework to improve the System namespace in .Net |
|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript |
|
Acheve.TestHost
Achve.TestHost is a nuget package to improve TestServer experiences. For more information see http://github.com/Xabaril/Acheve.TestHost |
|
Volo.Abp.AspNetCore.TestBase
Package Description |
GitHub repositories (215)
Showing the top 5 popular GitHub repositories that depend on Microsoft.AspNetCore.TestHost:
Repository | Stars |
---|---|
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
|
|
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
|
|
aspnetboilerplate/aspnetboilerplate
ASP.NET Boilerplate - Web Application Framework
|
|
dotnet/yarp
A toolkit for developing high-performance HTTP reverse proxy applications.
|
|
ThreeMammals/Ocelot
.NET API Gateway
|
Version | Downloads | Last updated | |
---|---|---|---|
10.0.0-preview.1.25120.3 | 904 | 2/25/2025 | |
9.0.3 | 0 | 3/11/2025 | |
9.0.2 | 627,070 | 2/11/2025 | |
9.0.1 | 797,968 | 1/14/2025 | |
9.0.0 | 2,032,540 | 11/12/2024 | |
9.0.0-rc.2.24474.3 | 45,559 | 10/8/2024 | |
9.0.0-rc.1.24452.1 | 34,255 | 9/10/2024 | |
9.0.0-preview.7.24406.2 | 7,462 | 8/13/2024 | |
9.0.0-preview.6.24328.4 | 11,641 | 7/9/2024 | |
9.0.0-preview.5.24306.11 | 3,742 | 6/11/2024 | |
9.0.0-preview.4.24267.6 | 2,209 | 5/21/2024 | |
9.0.0-preview.3.24172.13 | 69,386 | 4/11/2024 | |
9.0.0-preview.2.24128.4 | 2,858 | 3/12/2024 | |
9.0.0-preview.1.24081.5 | 24,103 | 2/13/2024 | |
8.0.14 | 0 | 3/11/2025 | |
8.0.13 | 467,667 | 2/11/2025 | |
8.0.12 | 864,582 | 1/14/2025 | |
8.0.11 | 3,162,267 | 11/12/2024 | |
8.0.10 | 4,945,772 | 10/8/2024 | |
8.0.8 | 6,100,756 | 8/13/2024 | |
8.0.7 | 4,539,813 | 7/9/2024 | |
8.0.6 | 4,791,243 | 5/28/2024 | |
8.0.5 | 1,691,119 | 5/14/2024 | |
8.0.4 | 4,260,824 | 4/9/2024 | |
8.0.3 | 3,084,798 | 3/12/2024 | |
8.0.2 | 3,191,771 | 2/13/2024 | |
8.0.1 | 3,608,855 | 1/9/2024 | |
8.0.0 | 5,209,984 | 11/14/2023 | |
8.0.0-rc.2.23480.2 | 63,605 | 10/10/2023 | |
8.0.0-rc.1.23421.29 | 57,892 | 9/12/2023 | |
8.0.0-preview.7.23375.9 | 12,349 | 8/8/2023 | |
8.0.0-preview.6.23329.11 | 42,758 | 7/11/2023 | |
8.0.0-preview.5.23302.2 | 12,562 | 6/13/2023 | |
8.0.0-preview.4.23260.4 | 215,295 | 5/16/2023 | |
8.0.0-preview.3.23177.8 | 3,001 | 4/11/2023 | |
8.0.0-preview.2.23153.2 | 1,783 | 3/14/2023 | |
8.0.0-preview.1.23112.2 | 41,349 | 2/21/2023 | |
7.0.20 | 385,431 | 5/28/2024 | |
7.0.19 | 63,346 | 5/14/2024 | |
7.0.18 | 178,642 | 4/9/2024 | |
7.0.17 | 358,193 | 3/12/2024 | |
7.0.16 | 374,542 | 2/13/2024 | |
7.0.15 | 602,930 | 1/9/2024 | |
7.0.14 | 1,014,968 | 11/14/2023 | |
7.0.13 | 1,637,096 | 10/24/2023 | |
7.0.12 | 1,050,209 | 10/10/2023 | |
7.0.11 | 2,586,105 | 9/12/2023 | |
7.0.10 | 1,733,065 | 8/8/2023 | |
7.0.9 | 1,321,222 | 7/11/2023 | |
7.0.8 | 1,076,022 | 6/22/2023 | |
7.0.7 | 501,005 | 6/13/2023 | |
7.0.5 | 3,614,204 | 4/11/2023 | |
7.0.4 | 1,987,622 | 3/14/2023 | |
7.0.3 | 1,709,511 | 2/14/2023 | |
7.0.2 | 1,813,331 | 1/10/2023 | |
7.0.1 | 1,048,124 | 12/13/2022 | |
7.0.0 | 3,309,754 | 11/7/2022 | |
7.0.0-rc.2.22476.2 | 67,453 | 10/11/2022 | |
7.0.0-rc.1.22427.2 | 22,416 | 9/14/2022 | |
7.0.0-preview.7.22376.6 | 10,610 | 8/9/2022 | |
7.0.0-preview.6.22330.3 | 3,789 | 7/12/2022 | |
7.0.0-preview.5.22303.8 | 9,486 | 6/14/2022 | |
7.0.0-preview.4.22251.1 | 2,204 | 5/10/2022 | |
7.0.0-preview.3.22178.4 | 1,242 | 4/13/2022 | |
7.0.0-preview.2.22153.2 | 1,027 | 3/14/2022 | |
7.0.0-preview.1.22109.13 | 4,977 | 2/17/2022 | |
6.0.36 | 325,498 | 11/12/2024 | |
6.0.35 | 190,038 | 10/8/2024 | |
6.0.33 | 700,647 | 8/13/2024 | |
6.0.32 | 293,728 | 7/9/2024 | |
6.0.31 | 480,725 | 5/28/2024 | |
6.0.30 | 162,636 | 5/14/2024 | |
6.0.29 | 707,762 | 4/9/2024 | |
6.0.28 | 437,385 | 3/12/2024 | |
6.0.27 | 783,577 | 2/13/2024 | |
6.0.26 | 1,033,347 | 1/9/2024 | |
6.0.25 | 1,691,137 | 11/14/2023 | |
6.0.24 | 911,603 | 10/24/2023 | |
6.0.23 | 598,811 | 10/10/2023 | |
6.0.22 | 1,026,834 | 9/12/2023 | |
6.0.21 | 1,574,407 | 8/8/2023 | |
6.0.20 | 1,399,064 | 7/11/2023 | |
6.0.19 | 865,971 | 6/22/2023 | |
6.0.18 | 578,361 | 6/13/2023 | |
6.0.16 | 3,129,396 | 4/11/2023 | |
6.0.15 | 1,881,997 | 3/14/2023 | |
6.0.14 | 2,183,563 | 2/14/2023 | |
6.0.13 | 2,809,000 | 1/10/2023 | |
6.0.12 | 2,799,452 | 12/13/2022 | |
6.0.11 | 3,543,129 | 11/7/2022 | |
6.0.10 | 5,153,859 | 10/11/2022 | |
6.0.9 | 3,929,678 | 9/13/2022 | |
6.0.8 | 4,717,202 | 8/9/2022 | |
6.0.7 | 4,196,592 | 7/12/2022 | |
6.0.6 | 3,204,955 | 6/14/2022 | |
6.0.5 | 4,094,913 | 5/10/2022 | |
6.0.4 | 3,742,407 | 4/11/2022 | |
6.0.3 | 4,401,013 | 3/8/2022 | |
6.0.2 | 3,693,544 | 2/8/2022 | |
6.0.1 | 5,548,789 | 12/14/2021 | |
6.0.0 | 6,477,735 | 11/8/2021 | |
6.0.0-rc.2.21480.10 | 205,221 | 10/12/2021 | |
6.0.0-rc.1.21452.15 | 175,023 | 9/14/2021 | |
6.0.0-preview.7.21378.6 | 9,095 | 8/10/2021 | |
6.0.0-preview.6.21355.2 | 5,033 | 7/14/2021 | |
6.0.0-preview.5.21301.17 | 3,507 | 6/15/2021 | |
6.0.0-preview.4.21253.5 | 2,755 | 5/24/2021 | |
6.0.0-preview.3.21201.13 | 2,966 | 4/8/2021 | |
6.0.0-preview.2.21154.6 | 992 | 3/11/2021 | |
6.0.0-preview.1.21103.6 | 1,351 | 2/12/2021 | |
5.0.17 | 876,836 | 5/10/2022 | |
5.0.16 | 152,079 | 4/11/2022 | |
5.0.15 | 264,317 | 3/8/2022 | |
5.0.14 | 245,754 | 2/8/2022 | |
5.0.13 | 666,162 | 12/14/2021 | |
5.0.12 | 787,192 | 11/7/2021 | |
5.0.11 | 1,428,827 | 10/12/2021 | |
5.0.10 | 1,452,898 | 9/14/2021 | |
5.0.9 | 1,542,191 | 8/10/2021 | |
5.0.8 | 1,198,944 | 7/13/2021 | |
5.0.7 | 1,631,352 | 6/8/2021 | |
5.0.6 | 1,305,729 | 5/11/2021 | |
5.0.5 | 1,852,068 | 4/6/2021 | |
5.0.4 | 1,071,735 | 3/9/2021 | |
5.0.3 | 1,288,423 | 2/9/2021 | |
5.0.2 | 1,295,399 | 1/12/2021 | |
5.0.1 | 879,338 | 12/8/2020 | |
5.0.0 | 2,112,869 | 11/9/2020 | |
5.0.0-rc.2.20475.17 | 17,799 | 10/13/2020 | |
5.0.0-rc.1.20451.17 | 183,549 | 9/14/2020 | |
5.0.0-preview.8.20414.8 | 9,362 | 8/25/2020 | |
5.0.0-preview.7.20365.19 | 4,295 | 7/21/2020 | |
5.0.0-preview.6.20312.15 | 2,096 | 6/25/2020 | |
5.0.0-preview.5.20279.2 | 942 | 6/10/2020 | |
5.0.0-preview.4.20257.10 | 1,563 | 5/18/2020 | |
5.0.0-preview.3.20215.14 | 1,950 | 4/23/2020 | |
5.0.0-preview.2.20167.3 | 861 | 4/2/2020 | |
5.0.0-preview.1.20124.5 | 1,059 | 3/16/2020 | |
3.1.32 | 620,489 | 12/13/2022 | |
3.1.31 | 139,560 | 11/8/2022 | |
3.1.30 | 680,618 | 10/11/2022 | |
3.1.29 | 98,019 | 9/13/2022 | |
3.1.28 | 148,146 | 8/9/2022 | |
3.1.27 | 164,433 | 7/12/2022 | |
3.1.26 | 149,096 | 6/14/2022 | |
3.1.25 | 217,398 | 5/10/2022 | |
3.1.24 | 180,319 | 4/11/2022 | |
3.1.23 | 343,286 | 3/8/2022 | |
3.1.22 | 908,657 | 12/14/2021 | |
3.1.21 | 733,475 | 11/7/2021 | |
3.1.20 | 620,661 | 10/11/2021 | |
3.1.19 | 441,384 | 9/14/2021 | |
3.1.18 | 1,026,671 | 8/10/2021 | |
3.1.17 | 836,689 | 7/13/2021 | |
3.1.16 | 743,310 | 6/8/2021 | |
3.1.15 | 736,269 | 5/11/2021 | |
3.1.14 | 1,567,863 | 4/6/2021 | |
3.1.13 | 1,209,834 | 3/9/2021 | |
3.1.12 | 964,194 | 2/9/2021 | |
3.1.11 | 1,139,043 | 1/12/2021 | |
3.1.10 | 2,966,455 | 11/9/2020 | |
3.1.9 | 3,164,962 | 10/13/2020 | |
3.1.8 | 3,188,421 | 9/8/2020 | |
3.1.7 | 2,433,831 | 8/11/2020 | |
3.1.6 | 2,371,114 | 7/14/2020 | |
3.1.5 | 3,640,386 | 6/9/2020 | |
3.1.4 | 2,258,132 | 5/12/2020 | |
3.1.3 | 3,787,952 | 3/24/2020 | |
3.1.2 | 2,832,312 | 2/18/2020 | |
3.1.1 | 3,161,025 | 1/14/2020 | |
3.1.0 | 3,301,484 | 12/3/2019 | |
3.1.0-preview3.19555.2 | 3,377 | 11/13/2019 | |
3.1.0-preview2.19528.8 | 1,055 | 11/1/2019 | |
3.1.0-preview1.19508.20 | 1,664 | 10/15/2019 | |
3.0.3 | 225,802 | 2/18/2020 | |
3.0.2 | 77,254 | 1/14/2020 | |
3.0.0 | 4,177,848 | 9/23/2019 | |
3.0.0-rc1.19457.4 | 15,585 | 9/16/2019 | |
3.0.0-preview9.19424.4 | 8,993 | 9/4/2019 | |
3.0.0-preview8.19405.7 | 36,206 | 8/13/2019 | |
3.0.0-preview7.19365.7 | 13,843 | 7/23/2019 | |
3.0.0-preview6.19307.2 | 7,190 | 6/12/2019 | |
3.0.0-preview5-19227-01 | 11,600 | 5/6/2019 | |
3.0.0-preview4-19216-03 | 2,209 | 4/18/2019 | |
3.0.0-preview3-19153-02 | 2,066 | 3/6/2019 | |
3.0.0-preview-19075-0444 | 7,306 | 1/29/2019 | |
3.0.0-preview-18579-0056 | 4,300 | 12/3/2018 | |
2.3.0 | 2,342 | 1/14/2025 | |
2.2.0 | 12,543,849 | 12/3/2018 | |
2.2.0-preview3-35497 | 23,490 | 10/17/2018 | |
2.2.0-preview2-35157 | 13,032 | 9/12/2018 | |
2.2.0-preview1-35029 | 13,753 | 8/22/2018 | |
2.1.1 | 7,127,650 | 6/18/2018 | |
2.1.0 | 1,545,711 | 5/29/2018 | |
2.1.0-rc1-final | 36,668 | 5/6/2018 | |
2.1.0-preview2-final | 13,154 | 4/10/2018 | |
2.1.0-preview1-final | 28,339 | 2/26/2018 | |
2.0.3 | 265,904 | 5/7/2018 | |
2.0.2 | 720,262 | 3/13/2018 | |
2.0.1 | 1,293,624 | 11/14/2017 | |
2.0.0 | 989,755 | 8/11/2017 | |
2.0.0-preview2-final | 10,118 | 6/28/2017 | |
2.0.0-preview1-final | 20,823 | 5/10/2017 | |
1.1.3 | 135,335 | 9/20/2017 | |
1.1.2 | 560,646 | 5/9/2017 | |
1.1.1 | 276,991 | 3/6/2017 | |
1.1.0 | 364,106 | 11/16/2016 | |
1.1.0-preview1-final | 5,640 | 10/24/2016 | |
1.0.5 | 23,504 | 11/14/2017 | |
1.0.4 | 4,493 | 9/20/2017 | |
1.0.3 | 57,162 | 5/9/2017 | |
1.0.2 | 165,062 | 3/6/2017 | |
1.0.1 | 14,448 | 12/12/2016 | |
1.0.0 | 292,126 | 6/27/2016 | |
1.0.0-rc2-final | 15,776 | 5/16/2016 |