WebApplicationFactory
Starts your app in memory for integration tests.
What is WebApplicationFactory?
WebApplicationFactory<T> starts your whole app in memory for integration tests and gives you an HttpClient to call it, with the option to swap services.
public class RecipeApiTests(WebApplicationFactory<Program> factory) : IClassFixture<WebApplicationFactory<Program>>
{
[Fact]
public async Task GetRecipes_ReturnsOk()
{
var response = await factory.CreateClient().GetAsync("/recipes");
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
}
Level: Journeyman · More ASP.NET Core terms at this level
Updated