C++Now 2017: Peter Bindels "Mocking C++"
Channel: CppNow
Date: 2017-06-06

http://cppnow.org
—
Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/boostcon/cppnow_presentations_2017
—
When unit testing, many times you'll be re-testing already tested components, unnecessarily slowing down your code or pulling in dependencies and unreliabilities you'd like to avoid. There's a way to avoid that - use a mock component that pretends to do what you ask it to, but that instead just gives you the answers your test needs. It's a much easier way to get your tests for corner cases and bad return values written, and it makes them more reliable to boot. 

The downside is that to implement it properly, you would need to have reflection. Java and C#, both with great mocking libraries use reflection to create their mock objects, and many times it's been posed that C++ just cannot do it without many macros, manual labor, unreliable scripts or duplicated code, because it lacks the ability. We show otherwise - unlike some C++ mocking libraries would have you believe, you can actually make mock objects without repeating - or implementing for the first time! - the classes you're testing with.
— 
Original/first author of HippoMocks (github.com/dascandy/hippomocks), first author of cpp-dependencies (github.com/tomtom-international/cpp-dependencies), long-standing moderator at forum.osdev.org. Convinced of the ability of people to make things more complicated than they actually are and working on making it all-around possible to show things aren't actually as complicated as they seem.
—
Videos Filmed & Edited by Bash Films: http://www.BashFilms.com
---

*--*

---