Fracanto Dependency Injection

Fracanto Dependency Injection #3 — Testability

Testability as an Architectural Decision

Testability as an Architectural Decision

The consistent DI implementation enables all 348 unit tests to run on macOS without any real hardware connected. The tests inject mock functions that record calls and return predefined results. The same driver code that runs with mocks in tests runs on the STM32 with real SPI, I2S, and GPIO functions — without changing a single line.

The M6 test fixture for the STM32G431KB's internal DAC/ADC also follows this pattern: dac_write_raw and adc_read_raw are injected, enabling 212 mock tests on the host and simultaneously the hardware roundtrip test over the real CAN-FD bus.