Using Trompeloeil - a mocking framework for modern C++
summary
Trompeloeil is a single-header C++14 mocking framework (≈3.5k lines, Boost license, available via Conan) that avoids UB and supports mocking member functions, templates and move-only types. The demo builds a mock store and Order class with TDD: using make_mock, require_call/allow_call/forbid_call (named variants), times and sequence to control ordering, underscore matcher and positional _1 with LR captures, side_effect and return for behavior, plus custom printing and named expectations to manage lifetime. Tests expose and fix real bugs; the example ends green.
AI-written summary · about
chapters (8)
- 0:00Introduction to Trompeloeil
- 2:46Framework design and setup
- 6:47Basic mocking examples
- 11:53Advanced expectation handling
- 20:32Templatized mocks and types
- 32:02Complex behavior simulation
- 40:24Callback testing techniques
- 47:31Wrap up and cheat sheet








