GMock
Google Mock (GMock) generates mock objects from interfaces. Instead of passing a real database, filesystem, or network client to the code under test, you pass a mock that records calls and lets you assert on them. This isolates the unit under test from its dependencies, making tests fast, deterministic, and independent of external systems.
Mocking Hardware
Unit Testing Firmware drew a clean line around the logic that needs nothing from the hardware at all — a parser, a state machine, a checksum — and pointed at this page for the harder case: logic whose whole job is to talk to a peripheral. A driver cannot be tested by giving it inputs and checking outputs the way a parser can, because its inputs and outputs are register writes and register reads, and there is no register to read from on a laptop. Testing it on the host requires something on the other end of the bus that behaves like the real device without being it.
Subsystems as Unreal's dependency-injection story
Before subsystems existed, "I need one instance of this system, reachable from anywhere" meant a
Writing a Driver Worth Reusing
Most firmware drivers are written once, for one board, and thrown away at the next project — not because the author was careless but because the driver was never separable from the chip it was born on. It calls HALI2CMaster_Transmit. It hard-codes I2C1. It has a static state variable so there can only ever be one. It blocks forever waiting on a status bit. Each of those is a small local convenience and together they weld the driver to one MCU, one instance, one board and one timing assumption.