liveBook · Manning

Brittle test

A brittle test is a test that is unusually prone to failure from incidental conditions or implementation changes even when the tested behavior remains correct.

How 3 Manning books explain it

Unit Testing Principles, Practices, and Patterns

Test fragility is the tendency of a test to fail when implementation changes without changing the tested behavior.

How it is used
Identifies tests that trade refactoring resistance for fast feedback and regression detection.
How deep it goes
Explains false positives, implementation-detail coupling, mock usage, and private-method refactoring, but stops short of exhaustive mocking techniques.
Examples
Uses exact SQL assertions, exposed normalization methods, mocked dependencies, and complex private pricing logic as fragility examples.
What you can do after
Diagnose false positives and refactor tests toward observable behavior without exposing private implementation details.

Read how Unit Testing Principles, Practices, and Patterns explains brittle test →

100 Go Mistakes and How to Avoid Them

A brittle test is a test whose result is unusually sensitive to incidental conditions such as timing, environment, or implementation details.

How it is used
Diagnoses timing-dependent unit-test failures and guides more robust tests for functions using the time API.
How deep it goes
Explains a concrete failure and compares clock injection with explicit-time alternatives, without covering every technique.
Examples
Uses an in-memory event cache, millisecond offsets, fixed timestamps, and an injectable now function.
What you can do after
Diagnose timing sensitivity and redesign tests around injected or explicitly supplied time.

Read how 100 Go Mistakes and How to Avoid Them explains brittle test →

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.

How it is used
Guides integration tests toward externally observable behavior instead of application implementation details.
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 you can do after
Apply behavior-focused assertions through an ASP.NET Core integration test using WebApplicationFactory.

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

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.