Microsoft.AspNetCore.TestHost 10.0.0-rc.1.25451.107
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 |
---|
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/954f61dd38b33caa2b736c73530bd5a294174437
|
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/36be7ed6d6d56b7da0a2891e3de7ecc2aa48eecd
|
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/610fe433e07b32ed451ed99d07df63be47c29050
|
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/4ae1269bff83362236d0f3bd4c9302e6a1e9341c
|
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/0a715692d8e2536c899faa0bb4f0cec2c2e33e36
|
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/cec88a329584349fda070f4c7346b10538210ace
|
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/cd9340856ed85215a911c97c44d52373f6cba2f9
|
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/8486d31e24f30e3fa1809a95699a0adc16f448d7
|
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications.
This package was built from the source code at https://github.com/aspnet/AspNetCore/tree/d12868dd7c10ff0433c16b06d3b59d03c40d987a
|
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/d827c653b787c07de908240b7746ce34d3e6271e
|
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications.
|
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/6a01dd1e69c8b9bd1ae005ea465ef2bcd26294bf
|
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications.
This package was built from the source code at https://github.com/aspnet/AspNetCore/tree/561deb05ae2d6680206e3d4a6bc75de699585980
|
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/67acc3d331454956fc06d6de2218a625e3e596f8
|
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications.
This package was built from the source code at https://github.com/aspnet/AspNetCore/tree/bd1e14b7d16b798de8a874189c89afed755a266c
|
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/e5f183b656a0e8bc087108130a5a9b54ae94494e
|
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/ed74665e773dd1ebea3289c5662d71c590305932
|
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/c9e3996173cec136bc2e9f3b4ec45f2a323b1d63
|
Microsoft.AspNetCore.Mvc.Testing
Support for writing functional tests for MVC applications.
This package was built from the source code at https://github.com/aspnet/AspNetCore/tree/67e04394e98d5bfa6a5684d471a72fcbe30fd587
|
.NET 10.0
- No dependencies.