All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Understanding Why Overly Aggressive Mocks Break Later in Software Testing

By

ingve

6mo ago· 4 min readen

Summary

The article explains why overly aggressive mocking in software testing can appear to work initially but break later. It discusses the rule of mocking where objects are used rather than where they're defined, and how violating this rule can lead to tests that pass temporarily but fail when code changes or when tests are run in different environments. The author uses code examples to illustrate how mocks that are too specific can create fragile tests that break unexpectedly.

Key quotes

· 4 pulled
Mock where the object is used, not where it's defined.
An overly aggressive mock can work fine, but then break much later.
The test will only pass if you create the correct settings.json file in the right location.
In some cases, the mock will work even if you don't follow this rule, and then it can break much later.
Snippet from the RSS feed
An overly aggressive mock can work fine, but then break much later. Why?

You might also wanna read