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 (214)
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 | 361 | 2/25/2025 | |
9.0.2 | 282,926 | 2/11/2025 | |
9.0.1 | 587,952 | 1/14/2025 | |
9.0.0 | 1,781,736 | 11/12/2024 | |
9.0.0-rc.2.24474.3 | 43,096 | 10/8/2024 | |
9.0.0-rc.1.24452.1 | 33,470 | 9/10/2024 | |
9.0.0-preview.7.24406.2 | 7,438 | 8/13/2024 | |
9.0.0-preview.6.24328.4 | 11,507 | 7/9/2024 | |
9.0.0-preview.5.24306.11 | 3,721 | 6/11/2024 | |
9.0.0-preview.4.24267.6 | 2,193 | 5/21/2024 | |
9.0.0-preview.3.24172.13 | 69,374 | 4/11/2024 | |
9.0.0-preview.2.24128.4 | 2,832 | 3/12/2024 | |
9.0.0-preview.1.24081.5 | 23,940 | 2/13/2024 | |
8.0.13 | 207,166 | 2/11/2025 | |
8.0.12 | 625,480 | 1/14/2025 | |
8.0.11 | 2,677,401 | 11/12/2024 | |
8.0.10 | 4,493,900 | 10/8/2024 | |
8.0.8 | 5,705,580 | 8/13/2024 | |
8.0.7 | 4,304,884 | 7/9/2024 | |
8.0.6 | 4,620,222 | 5/28/2024 | |
8.0.5 | 1,578,260 | 5/14/2024 | |
8.0.4 | 4,067,171 | 4/9/2024 | |
8.0.3 | 2,961,162 | 3/12/2024 | |
8.0.2 | 3,109,378 | 2/13/2024 | |
8.0.1 | 3,513,107 | 1/9/2024 | |
8.0.0 | 4,999,625 | 11/14/2023 | |
8.0.0-rc.2.23480.2 | 63,348 | 10/10/2023 | |
8.0.0-rc.1.23421.29 | 56,777 | 9/12/2023 | |
8.0.0-preview.7.23375.9 | 12,233 | 8/8/2023 | |
8.0.0-preview.6.23329.11 | 42,566 | 7/11/2023 | |
8.0.0-preview.5.23302.2 | 12,541 | 6/13/2023 | |
8.0.0-preview.4.23260.4 | 196,971 | 5/16/2023 | |
8.0.0-preview.3.23177.8 | 2,979 | 4/11/2023 | |
8.0.0-preview.2.23153.2 | 1,768 | 3/14/2023 | |
8.0.0-preview.1.23112.2 | 41,304 | 2/21/2023 | |
7.0.20 | 357,407 | 5/28/2024 | |
7.0.19 | 60,687 | 5/14/2024 | |
7.0.18 | 171,872 | 4/9/2024 | |
7.0.17 | 321,364 | 3/12/2024 | |
7.0.16 | 364,012 | 2/13/2024 | |
7.0.15 | 596,543 | 1/9/2024 | |
7.0.14 | 1,005,905 | 11/14/2023 | |
7.0.13 | 1,563,095 | 10/24/2023 | |
7.0.12 | 1,043,086 | 10/10/2023 | |
7.0.11 | 2,457,007 | 9/12/2023 | |
7.0.10 | 1,721,681 | 8/8/2023 | |
7.0.9 | 1,306,638 | 7/11/2023 | |
7.0.8 | 1,067,905 | 6/22/2023 | |
7.0.7 | 492,960 | 6/13/2023 | |
7.0.5 | 3,561,578 | 4/11/2023 | |
7.0.4 | 1,974,473 | 3/14/2023 | |
7.0.3 | 1,696,219 | 2/14/2023 | |
7.0.2 | 1,802,201 | 1/10/2023 | |
7.0.1 | 1,040,828 | 12/13/2022 | |
7.0.0 | 3,257,671 | 11/7/2022 | |
7.0.0-rc.2.22476.2 | 67,136 | 10/11/2022 | |
7.0.0-rc.1.22427.2 | 22,258 | 9/14/2022 | |
7.0.0-preview.7.22376.6 | 10,585 | 8/9/2022 | |
7.0.0-preview.6.22330.3 | 3,772 | 7/12/2022 | |
7.0.0-preview.5.22303.8 | 9,470 | 6/14/2022 | |
7.0.0-preview.4.22251.1 | 2,187 | 5/10/2022 | |
7.0.0-preview.3.22178.4 | 1,195 | 4/13/2022 | |
7.0.0-preview.2.22153.2 | 989 | 3/14/2022 | |
7.0.0-preview.1.22109.13 | 4,931 | 2/17/2022 | |
6.0.36 | 219,543 | 11/12/2024 | |
6.0.35 | 177,096 | 10/8/2024 | |
6.0.33 | 652,631 | 8/13/2024 | |
6.0.32 | 282,054 | 7/9/2024 | |
6.0.31 | 465,566 | 5/28/2024 | |
6.0.30 | 159,672 | 5/14/2024 | |
6.0.29 | 687,491 | 4/9/2024 | |
6.0.28 | 429,002 | 3/12/2024 | |
6.0.27 | 739,238 | 2/13/2024 | |
6.0.26 | 1,005,126 | 1/9/2024 | |
6.0.25 | 1,660,890 | 11/14/2023 | |
6.0.24 | 902,299 | 10/24/2023 | |
6.0.23 | 589,962 | 10/10/2023 | |
6.0.22 | 1,013,268 | 9/12/2023 | |
6.0.21 | 1,549,779 | 8/8/2023 | |
6.0.20 | 1,380,075 | 7/11/2023 | |
6.0.19 | 855,213 | 6/22/2023 | |
6.0.18 | 571,132 | 6/13/2023 | |
6.0.16 | 3,093,522 | 4/11/2023 | |
6.0.15 | 1,854,363 | 3/14/2023 | |
6.0.14 | 2,154,525 | 2/14/2023 | |
6.0.13 | 2,761,665 | 1/10/2023 | |
6.0.12 | 2,770,410 | 12/13/2022 | |
6.0.11 | 3,470,575 | 11/7/2022 | |
6.0.10 | 5,115,633 | 10/11/2022 | |
6.0.9 | 3,895,464 | 9/13/2022 | |
6.0.8 | 4,677,816 | 8/9/2022 | |
6.0.7 | 4,163,775 | 7/12/2022 | |
6.0.6 | 3,182,531 | 6/14/2022 | |
6.0.5 | 4,072,527 | 5/10/2022 | |
6.0.4 | 3,715,691 | 4/11/2022 | |
6.0.3 | 4,372,195 | 3/8/2022 | |
6.0.2 | 3,670,326 | 2/8/2022 | |
6.0.1 | 5,507,929 | 12/14/2021 | |
6.0.0 | 6,415,208 | 11/8/2021 | |
6.0.0-rc.2.21480.10 | 204,960 | 10/12/2021 | |
6.0.0-rc.1.21452.15 | 174,899 | 9/14/2021 | |
6.0.0-preview.7.21378.6 | 9,073 | 8/10/2021 | |
6.0.0-preview.6.21355.2 | 4,999 | 7/14/2021 | |
6.0.0-preview.5.21301.17 | 3,474 | 6/15/2021 | |
6.0.0-preview.4.21253.5 | 2,485 | 5/24/2021 | |
6.0.0-preview.3.21201.13 | 2,374 | 4/8/2021 | |
6.0.0-preview.2.21154.6 | 967 | 3/11/2021 | |
6.0.0-preview.1.21103.6 | 1,326 | 2/12/2021 | |
5.0.17 | 867,498 | 5/10/2022 | |
5.0.16 | 151,304 | 4/11/2022 | |
5.0.15 | 263,242 | 3/8/2022 | |
5.0.14 | 244,711 | 2/8/2022 | |
5.0.13 | 664,040 | 12/14/2021 | |
5.0.12 | 784,944 | 11/7/2021 | |
5.0.11 | 1,423,923 | 10/12/2021 | |
5.0.10 | 1,449,369 | 9/14/2021 | |
5.0.9 | 1,538,168 | 8/10/2021 | |
5.0.8 | 1,195,095 | 7/13/2021 | |
5.0.7 | 1,624,333 | 6/8/2021 | |
5.0.6 | 1,302,923 | 5/11/2021 | |
5.0.5 | 1,845,419 | 4/6/2021 | |
5.0.4 | 1,069,653 | 3/9/2021 | |
5.0.3 | 1,286,866 | 2/9/2021 | |
5.0.2 | 1,294,117 | 1/12/2021 | |
5.0.1 | 878,045 | 12/8/2020 | |
5.0.0 | 2,098,100 | 11/9/2020 | |
5.0.0-rc.2.20475.17 | 17,759 | 10/13/2020 | |
5.0.0-rc.1.20451.17 | 183,518 | 9/14/2020 | |
5.0.0-preview.8.20414.8 | 9,333 | 8/25/2020 | |
5.0.0-preview.7.20365.19 | 4,265 | 7/21/2020 | |
5.0.0-preview.6.20312.15 | 2,070 | 6/25/2020 | |
5.0.0-preview.5.20279.2 | 917 | 6/10/2020 | |
5.0.0-preview.4.20257.10 | 1,539 | 5/18/2020 | |
5.0.0-preview.3.20215.14 | 1,914 | 4/23/2020 | |
5.0.0-preview.2.20167.3 | 835 | 4/2/2020 | |
5.0.0-preview.1.20124.5 | 1,033 | 3/16/2020 | |
3.1.32 | 608,131 | 12/13/2022 | |
3.1.31 | 138,232 | 11/8/2022 | |
3.1.30 | 665,056 | 10/11/2022 | |
3.1.29 | 97,195 | 9/13/2022 | |
3.1.28 | 147,478 | 8/9/2022 | |
3.1.27 | 163,831 | 7/12/2022 | |
3.1.26 | 147,986 | 6/14/2022 | |
3.1.25 | 216,501 | 5/10/2022 | |
3.1.24 | 178,897 | 4/11/2022 | |
3.1.23 | 341,312 | 3/8/2022 | |
3.1.22 | 902,484 | 12/14/2021 | |
3.1.21 | 731,320 | 11/7/2021 | |
3.1.20 | 615,173 | 10/11/2021 | |
3.1.19 | 439,806 | 9/14/2021 | |
3.1.18 | 1,024,378 | 8/10/2021 | |
3.1.17 | 835,086 | 7/13/2021 | |
3.1.16 | 740,297 | 6/8/2021 | |
3.1.15 | 732,967 | 5/11/2021 | |
3.1.14 | 1,555,975 | 4/6/2021 | |
3.1.13 | 1,205,263 | 3/9/2021 | |
3.1.12 | 962,022 | 2/9/2021 | |
3.1.11 | 1,134,478 | 1/12/2021 | |
3.1.10 | 2,957,663 | 11/9/2020 | |
3.1.9 | 3,154,601 | 10/13/2020 | |
3.1.8 | 3,180,475 | 9/8/2020 | |
3.1.7 | 2,428,723 | 8/11/2020 | |
3.1.6 | 2,364,546 | 7/14/2020 | |
3.1.5 | 3,628,037 | 6/9/2020 | |
3.1.4 | 2,253,227 | 5/12/2020 | |
3.1.3 | 3,776,853 | 3/24/2020 | |
3.1.2 | 2,826,551 | 2/18/2020 | |
3.1.1 | 3,149,697 | 1/14/2020 | |
3.1.0 | 3,289,183 | 12/3/2019 | |
3.1.0-preview3.19555.2 | 3,350 | 11/13/2019 | |
3.1.0-preview2.19528.8 | 1,028 | 11/1/2019 | |
3.1.0-preview1.19508.20 | 1,636 | 10/15/2019 | |
3.0.3 | 225,150 | 2/18/2020 | |
3.0.2 | 77,184 | 1/14/2020 | |
3.0.0 | 4,162,127 | 9/23/2019 | |
3.0.0-rc1.19457.4 | 15,556 | 9/16/2019 | |
3.0.0-preview9.19424.4 | 8,966 | 9/4/2019 | |
3.0.0-preview8.19405.7 | 36,127 | 8/13/2019 | |
3.0.0-preview7.19365.7 | 13,816 | 7/23/2019 | |
3.0.0-preview6.19307.2 | 7,162 | 6/12/2019 | |
3.0.0-preview5-19227-01 | 11,563 | 5/6/2019 | |
3.0.0-preview4-19216-03 | 2,171 | 4/18/2019 | |
3.0.0-preview3-19153-02 | 2,036 | 3/6/2019 | |
3.0.0-preview-19075-0444 | 7,262 | 1/29/2019 | |
3.0.0-preview-18579-0056 | 4,268 | 12/3/2018 | |
2.3.0 | 1,428 | 1/14/2025 | |
2.2.0 | 12,489,045 | 12/3/2018 | |
2.2.0-preview3-35497 | 23,437 | 10/17/2018 | |
2.2.0-preview2-35157 | 12,913 | 9/12/2018 | |
2.2.0-preview1-35029 | 13,702 | 8/22/2018 | |
2.1.1 | 7,102,283 | 6/18/2018 | |
2.1.0 | 1,537,078 | 5/29/2018 | |
2.1.0-rc1-final | 36,577 | 5/6/2018 | |
2.1.0-preview2-final | 13,068 | 4/10/2018 | |
2.1.0-preview1-final | 28,195 | 2/26/2018 | |
2.0.3 | 265,447 | 5/7/2018 | |
2.0.2 | 719,266 | 3/13/2018 | |
2.0.1 | 1,291,866 | 11/14/2017 | |
2.0.0 | 988,092 | 8/11/2017 | |
2.0.0-preview2-final | 10,054 | 6/28/2017 | |
2.0.0-preview1-final | 20,758 | 5/10/2017 | |
1.1.3 | 135,035 | 9/20/2017 | |
1.1.2 | 559,374 | 5/9/2017 | |
1.1.1 | 276,664 | 3/6/2017 | |
1.1.0 | 363,199 | 11/16/2016 | |
1.1.0-preview1-final | 5,567 | 10/24/2016 | |
1.0.5 | 23,414 | 11/14/2017 | |
1.0.4 | 4,425 | 9/20/2017 | |
1.0.3 | 57,094 | 5/9/2017 | |
1.0.2 | 164,761 | 3/6/2017 | |
1.0.1 | 14,380 | 12/12/2016 | |
1.0.0 | 290,532 | 6/27/2016 | |
1.0.0-rc2-final | 15,704 | 5/16/2016 |