Microsoft.AspNetCore.TestHost 10.0.0-preview.2.25164.1
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.
Showing the top 20 packages that depend on Microsoft.AspNetCore.TestHost.
Packages | Downloads |
---|---|
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
15 |
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
16 |
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
17 |
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
18 |
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
19 |
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
21 |
NSwag.Commands
NSwag: The OpenAPI/Swagger API toolchain for .NET and TypeScript
|
23 |
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
|
15 |
NSwag.Commands
NSwag: The Swagger API toolchain for .NET and TypeScript
|
16 |
.NET 10.0
- No dependencies.
Version | Downloads | Last updated |
---|---|---|
10.0.0-preview.2.25164.1 | 2 | 04/02/2025 |
10.0.0-preview.1.25120.3 | 2 | 04/02/2025 |
9.0.3 | 1 | 04/01/2025 |
9.0.2 | 2 | 04/01/2025 |
9.0.1 | 2 | 04/01/2025 |
9.0.0 | 12 | 11/15/2024 |
9.0.0-rc.2.24474.3 | 12 | 10/15/2024 |
9.0.0-rc.1.24452.1 | 10 | 10/05/2024 |
9.0.0-preview.7.24406.2 | 14 | 08/21/2024 |
9.0.0-preview.6.24328.4 | 25 | 07/21/2024 |
9.0.0-preview.5.24306.11 | 32 | 07/21/2024 |
9.0.0-preview.4.24267.6 | 32 | 07/21/2024 |
9.0.0-preview.3.24172.13 | 43 | 07/21/2024 |
9.0.0-preview.2.24128.4 | 24 | 07/21/2024 |
9.0.0-preview.1.24081.5 | 33 | 07/21/2024 |
8.0.14 | 2 | 04/01/2025 |
8.0.13 | 2 | 04/01/2025 |
8.0.12 | 2 | 04/01/2025 |
8.0.11 | 9 | 11/15/2024 |
8.0.10 | 11 | 10/14/2024 |
8.0.8 | 13 | 08/21/2024 |
8.0.7 | 25 | 07/21/2024 |
8.0.6 | 22 | 07/21/2024 |
8.0.5 | 27 | 07/21/2024 |
8.0.4 | 33 | 07/21/2024 |
8.0.3 | 28 | 07/21/2024 |
8.0.2 | 31 | 07/21/2024 |
8.0.1 | 38 | 07/21/2024 |
8.0.0 | 32 | 07/21/2024 |
8.0.0-rc.2.23480.2 | 27 | 07/21/2024 |
8.0.0-rc.1.23421.29 | 28 | 07/21/2024 |
8.0.0-preview.7.23375.9 | 23 | 07/21/2024 |
8.0.0-preview.6.23329.11 | 36 | 07/21/2024 |
8.0.0-preview.5.23302.2 | 30 | 07/21/2024 |
8.0.0-preview.4.23260.4 | 38 | 07/21/2024 |
8.0.0-preview.3.23177.8 | 36 | 07/21/2024 |
8.0.0-preview.2.23153.2 | 26 | 07/21/2024 |
8.0.0-preview.1.23112.2 | 32 | 07/21/2024 |
7.0.20 | 33 | 07/21/2024 |
7.0.19 | 29 | 07/21/2024 |
7.0.18 | 23 | 07/21/2024 |
7.0.17 | 25 | 07/21/2024 |
7.0.16 | 30 | 07/21/2024 |
7.0.15 | 25 | 07/21/2024 |
7.0.14 | 32 | 07/21/2024 |
7.0.13 | 31 | 07/21/2024 |
7.0.12 | 25 | 07/21/2024 |
7.0.11 | 32 | 07/21/2024 |
7.0.10 | 24 | 07/21/2024 |
7.0.9 | 24 | 07/21/2024 |
7.0.8 | 27 | 07/21/2024 |
7.0.7 | 31 | 07/21/2024 |
7.0.5 | 24 | 07/21/2024 |
7.0.4 | 33 | 07/21/2024 |
7.0.3 | 38 | 07/21/2024 |
7.0.2 | 30 | 07/21/2024 |
7.0.1 | 25 | 07/21/2024 |
7.0.0 | 25 | 07/21/2024 |
7.0.0-rc.2.22476.2 | 37 | 07/21/2024 |
7.0.0-rc.1.22427.2 | 27 | 07/21/2024 |
7.0.0-preview.7.22376.6 | 22 | 07/21/2024 |
7.0.0-preview.6.22330.3 | 31 | 07/21/2024 |
7.0.0-preview.5.22303.8 | 34 | 07/21/2024 |
7.0.0-preview.4.22251.1 | 22 | 07/21/2024 |
7.0.0-preview.3.22178.4 | 23 | 07/21/2024 |
7.0.0-preview.2.22153.2 | 29 | 07/21/2024 |
7.0.0-preview.1.22109.13 | 17 | 07/21/2024 |
6.0.36 | 8 | 11/15/2024 |
6.0.35 | 9 | 10/21/2024 |
6.0.33 | 10 | 08/21/2024 |
6.0.32 | 37 | 07/21/2024 |
6.0.31 | 27 | 07/21/2024 |
6.0.30 | 24 | 07/21/2024 |
6.0.29 | 26 | 07/21/2024 |
6.0.28 | 30 | 07/21/2024 |
6.0.27 | 28 | 07/21/2024 |
6.0.26 | 29 | 07/21/2024 |
6.0.25 | 33 | 07/21/2024 |
6.0.24 | 38 | 07/21/2024 |
6.0.23 | 30 | 07/21/2024 |
6.0.22 | 38 | 07/21/2024 |
6.0.21 | 32 | 07/21/2024 |
6.0.20 | 28 | 07/21/2024 |
6.0.19 | 28 | 07/21/2024 |
6.0.18 | 37 | 07/21/2024 |
6.0.16 | 23 | 07/21/2024 |
6.0.15 | 33 | 07/21/2024 |
6.0.14 | 34 | 07/21/2024 |
6.0.13 | 32 | 07/21/2024 |
6.0.12 | 33 | 07/21/2024 |
6.0.11 | 36 | 07/21/2024 |
6.0.10 | 35 | 07/21/2024 |
6.0.9 | 31 | 07/21/2024 |
6.0.8 | 30 | 07/21/2024 |
6.0.7 | 30 | 07/21/2024 |
6.0.6 | 36 | 07/21/2024 |
6.0.5 | 35 | 07/21/2024 |
6.0.4 | 35 | 07/21/2024 |
6.0.3 | 29 | 07/21/2024 |
6.0.2 | 25 | 07/21/2024 |
6.0.1 | 32 | 07/21/2024 |
6.0.0 | 30 | 07/21/2024 |
6.0.0-rc.2.21480.10 | 32 | 07/21/2024 |
6.0.0-rc.1.21452.15 | 30 | 07/21/2024 |
6.0.0-preview.7.21378.6 | 25 | 07/21/2024 |
6.0.0-preview.6.21355.2 | 26 | 07/21/2024 |
6.0.0-preview.5.21301.17 | 37 | 07/21/2024 |
6.0.0-preview.4.21253.5 | 40 | 07/21/2024 |
6.0.0-preview.3.21201.13 | 30 | 07/21/2024 |
6.0.0-preview.2.21154.6 | 29 | 07/21/2024 |
6.0.0-preview.1.21103.6 | 33 | 07/21/2024 |
5.0.17 | 31 | 07/21/2024 |
5.0.16 | 27 | 07/21/2024 |
5.0.15 | 18 | 07/21/2024 |
5.0.14 | 36 | 07/21/2024 |
5.0.13 | 34 | 07/21/2024 |
5.0.12 | 36 | 07/21/2024 |
5.0.11 | 35 | 07/21/2024 |
5.0.10 | 22 | 07/21/2024 |
5.0.9 | 26 | 07/21/2024 |
5.0.8 | 30 | 07/21/2024 |
5.0.7 | 23 | 07/21/2024 |
5.0.6 | 30 | 07/21/2024 |
5.0.5 | 31 | 07/21/2024 |
5.0.4 | 32 | 07/21/2024 |
5.0.3 | 30 | 07/21/2024 |
5.0.2 | 29 | 07/21/2024 |
5.0.1 | 31 | 07/21/2024 |
5.0.0 | 31 | 07/21/2024 |
5.0.0-rc.2.20475.17 | 30 | 07/21/2024 |
5.0.0-rc.1.20451.17 | 24 | 07/21/2024 |
5.0.0-preview.8.20414.8 | 32 | 07/21/2024 |
5.0.0-preview.7.20365.19 | 26 | 07/21/2024 |
5.0.0-preview.6.20312.15 | 35 | 07/21/2024 |
5.0.0-preview.5.20279.2 | 26 | 07/21/2024 |
5.0.0-preview.4.20257.10 | 34 | 07/21/2024 |
5.0.0-preview.3.20215.14 | 36 | 07/21/2024 |
5.0.0-preview.2.20167.3 | 23 | 07/21/2024 |
5.0.0-preview.1.20124.5 | 33 | 07/21/2024 |
3.1.32 | 33 | 07/21/2024 |
3.1.31 | 24 | 07/21/2024 |
3.1.30 | 23 | 07/21/2024 |
3.1.29 | 25 | 07/21/2024 |
3.1.28 | 30 | 07/21/2024 |
3.1.27 | 28 | 07/21/2024 |
3.1.26 | 28 | 07/21/2024 |
3.1.25 | 31 | 07/21/2024 |
3.1.24 | 28 | 07/21/2024 |
3.1.23 | 29 | 07/21/2024 |
3.1.22 | 34 | 07/21/2024 |
3.1.21 | 31 | 07/21/2024 |
3.1.20 | 28 | 07/21/2024 |
3.1.19 | 29 | 07/21/2024 |
3.1.18 | 29 | 07/21/2024 |
3.1.17 | 34 | 07/21/2024 |
3.1.16 | 30 | 07/21/2024 |
3.1.15 | 29 | 07/21/2024 |
3.1.14 | 33 | 07/21/2024 |
3.1.13 | 26 | 07/21/2024 |
3.1.12 | 30 | 07/21/2024 |
3.1.11 | 37 | 07/21/2024 |
3.1.10 | 41 | 07/21/2024 |
3.1.9 | 35 | 07/21/2024 |
3.1.8 | 30 | 07/21/2024 |
3.1.7 | 27 | 07/21/2024 |
3.1.6 | 34 | 07/21/2024 |
3.1.5 | 31 | 07/21/2024 |
3.1.4 | 30 | 07/21/2024 |
3.1.3 | 31 | 07/21/2024 |
3.1.2 | 32 | 07/21/2024 |
3.1.1 | 25 | 07/21/2024 |
3.1.0 | 31 | 07/21/2024 |
3.1.0-preview3.19555.2 | 42 | 07/21/2024 |
3.1.0-preview2.19528.8 | 18 | 07/21/2024 |
3.1.0-preview1.19508.20 | 23 | 07/21/2024 |
3.0.3 | 35 | 07/21/2024 |
3.0.2 | 28 | 07/21/2024 |
3.0.0 | 37 | 07/21/2024 |
3.0.0-rc1.19457.4 | 26 | 07/21/2024 |
3.0.0-preview9.19424.4 | 28 | 07/21/2024 |
3.0.0-preview8.19405.7 | 25 | 07/21/2024 |
3.0.0-preview7.19365.7 | 31 | 07/21/2024 |
3.0.0-preview6.19307.2 | 25 | 07/21/2024 |
3.0.0-preview5-19227-01 | 36 | 07/21/2024 |
3.0.0-preview4-19216-03 | 31 | 07/21/2024 |
3.0.0-preview3-19153-02 | 27 | 07/21/2024 |
3.0.0-preview-19075-0444 | 32 | 07/21/2024 |
3.0.0-preview-18579-0056 | 38 | 07/21/2024 |
2.3.0 | 2 | 04/01/2025 |
2.2.0 | 30 | 07/21/2024 |
2.2.0-preview3-35497 | 25 | 07/21/2024 |
2.2.0-preview2-35157 | 33 | 07/21/2024 |
2.2.0-preview1-35029 | 33 | 07/21/2024 |
2.1.1 | 22 | 07/21/2024 |
2.1.0 | 26 | 07/21/2024 |
2.1.0-rc1-final | 36 | 07/21/2024 |
2.1.0-preview2-final | 27 | 07/21/2024 |
2.1.0-preview1-final | 20 | 07/21/2024 |
2.0.3 | 24 | 07/21/2024 |
2.0.2 | 29 | 07/21/2024 |
2.0.1 | 33 | 07/21/2024 |
2.0.0 | 29 | 07/21/2024 |
2.0.0-preview2-final | 22 | 07/21/2024 |
2.0.0-preview1-final | 27 | 07/21/2024 |
1.1.3 | 37 | 07/21/2024 |
1.1.2 | 31 | 07/21/2024 |
1.1.1 | 32 | 07/21/2024 |
1.1.0 | 22 | 07/21/2024 |
1.1.0-preview1-final | 28 | 07/21/2024 |
1.0.5 | 35 | 07/21/2024 |
1.0.4 | 20 | 07/21/2024 |
1.0.3 | 23 | 07/21/2024 |
1.0.2 | 28 | 07/21/2024 |
1.0.1 | 27 | 07/21/2024 |
1.0.0 | 27 | 07/21/2024 |
1.0.0-rc2-final | 25 | 07/21/2024 |