Next generation unit testing using static reflection
summary
Claims a working unittest proof-of-concept for C++14 that uses compile-time static reflection to discover tests and non‑intrusively mock methods. It wires tinyrefl (a libclang codegen + metadata tool) to generate per-header metadata, uses function-table trampolines to patch method pointers at test time, and runs discovered test methods with automatic mocking. It runs but hits real limits: no global project reflection, no namespace member lists and limited attribute support, so full Python‑style patching depends on future reflection features.
AI-written summary · about
chapters (13)
- 0:00Introduction
- 1:15What is unit testing
- 3:25Problems with dependency injection
- 8:29Dependency injection for testing
- 13:30Unit testing without dependency injection
- 18:31Mocking in C++
- 20:17Non-intrusive mocking in C++
- 25:04Automatic test discovery
- 27:15Static reflection with TinyReflect
- 33:45Implementing test discovery
- 38:25Patching functions with reflection
- 40:53Reflection TS limitations
- 45:08Future ideas and Q&A
related talks
01h 01mReflection
46mBuilding a C++ Reflection System in One Weekend Using Clang and LLVM
01h 10mReflection Is Good for C++ Code Health
01h 01mAdvanced Unit Testing in C & C++
59mC++ Unit testing - the good, the bad & the ugly
06mMocking C++
01h 01mThe promise of static reflection in C++26: Type Traits without compiler intrinsics
01h 01m"unit"_test: Implementing a Macro-free Unit Testing Framework from Scratch in C++20
