Experimental package. Test fakes for integration testing
$ dotnet add package Microsoft.AspNetCore.TestingThis package provides test fakes for integration testing of ASP.NET Core applications.
In particular:
IWebHostBuilder extensions to setup the test web app.IHost extensions to access that test web app.From the command-line:
dotnet add package Microsoft.AspNetCore.Testing
Or directly in the C# project file:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="[CURRENTVERSION]" />
</ItemGroup>
The IWebHostBuilder extensions can help set up a host for testing.
using var host = await FakeHost.CreateBuilder()
.ConfigureWebHost(webHost => webHost.UseFakeStartup().ListenHttpOnAnyPort())
.StartAsync();
The IHost extensions can help access the test host that was created above.
using var client = host.CreateClient();
var response = await client.GetAsync("/");
We welcome feedback and contributions in our GitHub repo.