“Mocking Frameworks considered harmful”
summary
Argues that common C++ mocking frameworks (GoogleMock, Trompeloeil) introduce macro-heavy DSLs, late runtime verification on object destruction, and fragile white-box tests that over-specify call sequences and increase coupling. Shows practical alternatives: refactor to template seams or extracted interfaces, use IDE refactorings and linker/preprocessor seams, or generate plain C++ call traces with Mockator in Cevelop. Notes quirks like ON_CALL warnings driving overuse of EXPECT_CALL and demonstrates the generated stubs and traces work and give clearer failures.
AI-written summary · about
chapters (9)
- 0:00Introduction to mocking frameworks
- 1:47What is mocking and why use it
- 10:29When to use test doubles
- 17:40Introducing seams for testability
- 24:53Mocking frameworks in C++
- 35:00Problems with mocking frameworks
- 41:46History and limitations of mocking
- 47:42Dangers of over-mocking
- 51:17Q&A session
related talks
01h 18mMocking Framworks considered, harmful?!
06mMocking C++
53mUsing Trompeloeil - a mocking framework for modern C++
31mBeyond the Mockery- Why We Should Embrace Testing Without Mocking Frameworks
01h 25mUsing Trompeloeil, a mocking framework for modern C++
37mBeyond the Mockery: Why We Should Embrace Testing Without Mocking Frameworks
52mPlease don’t mock me
59mC++ Unit testing - the good, the bad & the ugly
