Testability and C++ API Design
summary
Shows concrete patterns: use the pimpl idiom to swap CPU and hardware CRC32 implementations (BlazingMQ) so one test environment covers both, prefer dependency injection via interfaces or templates with Google Mock for precise call and argument checks, and add RAII-style test-time source guards to advance schedulers instantly so unit tests run orders of magnitude faster. Offers abstract factory and channel-factory examples that expose test hooks, and proposes a boilerplate generator to auto-create interfaces, mocks, and tests.
AI-written summary · about
chapters (18)
- 0:00Introduction
- 1:06Testing basics
- 2:36The testing pyramid
- 5:09Motivation for testability
- 6:11SOLID design principles
- 9:28Additional considerations
- 10:00Techniques for testability
- 12:16Pimpl idiom
- 14:00BlazingMQ example
- 14:49Interface dependencies
- 19:27Adding test APIs
- 22:32Abstract factory pattern
- 24:28MWCIO channel factory
- 25:04Generalized mocking
- 29:53Dependency injection
- 32:33Challenges and solutions
- 34:03Proposed testing tool
- 35:25Q&A session
related talks
01h 00mTestability and API Design
59mC++ Unit testing - the good, the bad & the ugly
01h 01mAdvanced Unit Testing in C & C++
51mTestable by Design - How to Create Testable C++ Code Using C++ Language Features
01h 22mTest-Driven Development of C++ Embedded and System-Level Software
49mWorking with C++ Legacy Code
56mTestable by Design
53mC++ Unit testing - the good, the bad & the ugly
