liveBook · Manning

Brittle test

As explained in ASP.NET Core in Action, 3e

A brittle test is a test that fails when an implementation changes even though the externally observable behavior remains correct.

A brittle test fails when implementation details change, even though the application still produces the correct externally observable behavior. Prefer tests that verify responses and behavior rather than internal structure. section 36.3.2

Behavior-focused integration test

A test can send a GET request to /ping and check for a successful response and the expected result. It remains useful even if the middleware or other internal implementation changes, provided the application still responds correctly. section 36.3.2

How ASP.NET Core in Action, 3e covers it

How deep it goes
Defines brittleness and contrasts implementation-dependent tests with behavior-focused tests, but does not develop broader test-design techniques.
Examples
Uses a PingRequest_ReturnsPong test that creates an HttpClient, requests /ping, and ensures a successful response.
What it assumes
Assumes an ASP.NET Core application and xUnit test project, while explaining the required WebApplicationFactory fixture setup.
What you can do after
Apply behavior-focused assertions through an ASP.NET Core integration test using WebApplicationFactory.
How it connects
Connects brittle tests with integration testing, implementation details, WebApplicationFactory, xUnit, and TestServer.

Also explained in

Compare how 3 books explain brittle test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.