Over-Mocking and Snapshot Sprawl: Two Testing Pitfalls in Layered Systems
A developer writing about layered software architecture describes how certain tests become brittle and stop being useful. Over-mocking occurs when a test stubs dependencies deep inside another layer, so it breaks whenever that internal implementation changes even though behaviour is unchanged. The recommended remedy is to mock only at layer boundaries and, where possible, use small in-memory fakes that assert on outcomes rather than internal calls. Snapshot sprawl, common in the volatile UI layer, leads to noisy diffs that reviewers approve without reading, leaving tests unable to catch real regressions. Instead, the author suggests targeted assertions on what users rely on, reserving snapshots for small, stable outputs. The guiding question is whether a test would still pass if a layer's internals were rewritten while preserving its contract.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in