Testable by Design - How to Create Testable C++ Code Using C++ Language Features
summary
Builds a small heating controller (timer + thermostat + override activator) that composes an abstract heating activator API, uses fake implementations and Google Test to verify behaviors, and keeps time as std::chrono durations wrapped in a time window helper. Uses C++20 concepts (invocable) and CTAD, prefers shared_ptr for simple lifetime management, provides a factory for template activators, measures std::function vs templated callables and reports ~50% speed gain for templates, and shows examples compile with GCC/Clang/MSVC.
AI-written summary · about
chapters (10)
- 0:00Testable C++ design intro
- 5:27Heating controller system design
- 10:10Uncertainty in third-party APIs
- 15:09Controller with dependency injection
- 21:12Refactoring for testability
- 25:05Thermostat temperature separation
- 32:12Timer and override activators
- 38:52Manual override functionality
- 43:35Design principles summary
- 45:22Q&A
related talks
56mTestable by Design
46mTestability and C++ API Design
49mWorking with C++ Legacy Code
01h 18mTesting C++ Templates: Investigating Tests for C++ Templates using Adversarial Methods
01h 22mTest-Driven Development of C++ Embedded and System-Level Software
01h 01mBack to Basics: Test-driven Development
55mTemplates Made Easy With C++20
01h 40mTesting, Preconditions, Coverage and Templates in Safety-Critical C++ Code
