Mocks, Stubs, and Spies, Oh My!
summary
Covers five concrete test doubles — mocks, stubs, spies, dummies, fakes — and shows when to use each: mocks verify interactions and use mock(), when(...).thenReturn() style setup; stubs supply responder or sabotur values; spies combine recording plus return values or wrap real objects for side effects; fakes give fast in‑memory substitutes (common for databases) while avoiding overuse that leads to over‑specified fragile tests. Also notes Mockito-style tools can mock finals and that integration tests should avoid mocks.
AI-written summary · about
chapters (11)
- 0:00Introduction to test doubles
- 1:22Why use test doubles
- 5:53Types of tests explained
- 6:13Mocks explained
- 11:04Stubs explained
- 14:59Spies explained
- 20:00Dummies explained
- 22:11Fakes explained
- 25:04Common pitfalls with test doubles
- 27:31About the speaker
- 28:15Q&A session
related talks
30mMocks, Stubs, and Spies, Oh My
42mMocks, Fakes, Stubs – Is There a Difference? Do You Still Need Them?
41mMocks vs Fakes vs Stubs
47m"Testing with Doubles: Why, When, and How?"
40mTest Doubles are Not To Be Mocked
27mDe-mock your tests
59mJava Testing Part 2: Mocks, Stubs, and Spies with Mockito 4
27mFake Your Test Away: How To Abuse Your Test Doubles
