Alba 9 arrives with host pooling for parallel integration tests
Alba, JasperFx's ASP.NET Core integration testing library, is close to its 9.0 release, with RC3 published on October 25 as the last release candidate. The headline feature is a host pool that avoids spinning up fresh IHost instances and databases for every parallel test, joined by scenarios addressed by route name, JSONPath and problem details assertions, endpoint coverage and authorization audits, a fake TimeProvider for time travel, and server-sent events support.
Key points
- A host pool reuses rented hosts instead of building a new IHost and database per test; `MaxHosts` defaults to the processor count
- `OnCreated`, `OnRent` and `OnReturn` hooks reset data between tests, and a host left in a bad state is discarded and replaced in the same slot
- `RouteNamed`/`ToRouteNamed` address endpoints by route name, and an unknown name fails before the request is sent
- `JsonPath(...)` asserts on one JSON value, while `ShouldReturnProblemDetails` and `ShouldReturnValidationProblem` check RFC 9457 responses
- `EndpointCoverage.NotExercised()` reports endpoints no test reached and `EndpointsAllowingAnonymous()` lists endpoints reachable without credentials
- `TimeProviderOverride` injects a `FakeTimeProvider` you can move with `Advance`/`SetUtcNow`
Alba boots your real application in memory with `AlbaHost`, then runs each HTTP request through the actual ASP.NET Core pipeline so assertions see the full response. The centerpiece of 9.0 is the host pool in the `Alba.Pooling` namespace: the pool calls a factory as tests need hosts, and each host can be given its own database through `AlbaHostSlot.Index`. Tests rent a host with `RentAsync`, release it with `await using`, and rely on `OnCreated`, `OnRent` and `OnReturn` hooks to reset state between tests; `MaxHosts` defaults to the processor count.
Also new: scenarios can target an endpoint by route name (Minimal API `WithName()`, MVC `Name`, Wolverine's `RouteName`) and let the app's routing build the URL; `JsonPath(...)` asserts on a single value without deserializing the body, alongside RFC 9457 problem details assertions; audits list endpoints no test reached and endpoints reachable without credentials; and `TimeProviderOverride` swaps in a `FakeTimeProvider` you can advance. Read the changelog for the breaking changes from Alba 8.
Real-world use
- Running integration tests in parallel for an ASP.NET Core API whose CI time has become a bottleneck
- Giving each pooled host its own database or schema in a Marten- or EF Core-backed application
- Turning a missing `[Authorize]` into a failing test before a security review instead of a pen test finding
- Testing time-dependent behaviour such as subscription expiry, cache durations or scheduled messages with a fake clock
Why it matters
The host pool removes the per-test cost of starting hosts and databases that makes parallel integration testing painful, while the endpoint audits surface coverage and authorization gaps in CI rather than in production.