
Mocking Best Practices and Dependency Types

#58 - Principles for Writing Valuable Unit Tests - Vladimir Khorikov
Topic 15 of 18
Published Oct 4, 2021 · Clip 38:20–47:12 (8:52)
Vladimir discusses the two schools of mocking: the London (mockist) school, which mocks all mutable dependencies, and the classical school, which mocks only out-of-process dependencies. He argues both are flawed. Mocks should be used only when the communication with a dependency is part of the observable behavior—i.e., visible to the outside world. He introduces managed vs unmanaged dependencies: mock unmanaged ones (message bus, payment APIs, SMTP) but not managed ones like the application database.