liveBook · Manning

WebApplicationFactory

WebApplicationFactory is an ASP.NET Core testing API that bootstraps an application in an in-memory host and provides clients for functional and integration testing.

How 2 Manning books explain it

ASP.NET Core in Action, 3e

WebApplicationFactory is an ASP.NET Core testing API that bootstraps an application for in-memory functional and integration testing and permits test-specific customization.

How it is used
Tests a real ASP.NET Core application through in-memory HTTP requests and its configured framework pipeline.
How deep it goes
Explains setup, request verification, service replacement, and custom factories, but defers database-specific testing to a separate treatment.
Examples
Demonstrates GET /ping returning pong and a currency endpoint using a stub converter that returns 3.
What you can do after
Apply it via Microsoft.AspNetCore.Mvc.Testing to verify endpoints and substitute test services without starting an external server.

Read how ASP.NET Core in Action, 3e explains WebApplicationFactory →

.NET in Action, Second Edition

WebApplicationFactory is an ASP.NET Core testing API that creates an in-memory application host and a client for sending requests to it.

How it is used
Exercises an ASP.NET Core API across configuration, dependency injection, HTTP routing, and application logic without leaving the test process.
How deep it goes
Explains host creation, client-start timing, service replacement, environment selection, and response assertions, but not framework internals.
Examples
Uses a ComicFinderService, a fake external HTTP handler, and a search request whose JSON response is checked for one comic.
What you can do after
Diagnose integration behavior by sending real HTTP-style requests through a configured in-memory application and asserting complete responses.

Read how .NET in Action, Second Edition explains WebApplicationFactory →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.