Trompeloeil is a header-only C++14 mocking framework designed for ease of use without sacrificing expressive power. It uses macros like MAKE_MOCK, REQUIRE_CALL, and NAMED_REQUIRE_CALL to define mock classes and set expectations on method calls. Key features include sequence ordering of calls, wildcards, call count constraints (TIMES, AT_LEAST, AT_MOST), side effects, and the distinction between value-capture and reference-capture variants (LR_ prefix). The framework integrates with existing test runners and follows lifetime-based expectation enforcement via C++ scope rules.

6m read timeFrom playfulprogramming.com
Post cover image
Table of contents
Simple example Copy link Link copied!Expectations and fixtures Copy link Link copied!Mocking with side effects Copy link Link copied!Wrap-up Copy link Link copied!

Sort: