korrents

korrents · piece

“Don’t Mock What You Don’t Own” in 5 Minutes

Hynek Schlawack · 21 Jun 2022

Read the piece on hynek.me ↗

3 korrents from this piece ↓

Hynek Schlawack did not write this page.

Every claim below was made in this piece, quoted word for word and numbered in the order the piece makes them, so you can read it there rather than take our word for it. The sentence above each quote is our reading of the claim, not their wording. Each quote was checked against a stored copy of the page at build time; where the two differ, the quote is the fact.

  1. The principle Don't Mock What You Don't Own means that whenever you employ mock objects, you should use them to substitute your own objects and not third-party ones2.
  2. This is a business logic test and the purpose of the test is drowning in boilerplate necessary to mimic the API of an HTTP client that can change at any time. That makes the test brittle and unidiomatic.
  3. Corollary: To keep your business code testable and idiomatic, avoid directly using third-party dependencies in it.

Keep reading