Hardware TDD
Build the test ladder before claiming a feature is complete. Pure behavior can
often be tested off-target; voltage, pin mux, timing under load, and physical
assembly still require target evidence.
Intake
Record exact board/revision, framework/toolchain, hardware invariants, safety
inhibits, simulator model, available instruments, test fixtures, and the proof
stage required by the user.
Process
- Turn requirements into observable behavior and safety invariants.
- Write host tests for pure C/C++ logic using fakes for time, serial, sensors,
and actuators. Keep hardware adapters thin.
- Use Wokwi or another simulator only for peripherals and timing that its model
actually represents; record model limitations.
- Run an exact-board compile and static checks with the selected toolchain.
- Create a one-change target checklist: power-off continuity, controlled
power-up, input observation, output inhibit, reset/recovery, and logs.
- Ask a physical gate for measurements, photos, or serial output. Do not infer
target success from a host test or compile log.
- Record failures as evidence and keep the next test bounded.
Test matrix
| Layer |
Example |
Proves |
Does not prove |
| Host |
debounce/state/packet parser |
deterministic logic |
pin voltage or wiring |
| Simulation |
modeled sensor/LED/UART |
modeled interactions |
regulator, clone, EMI, thermal behavior |
| Build |
exact FQBN/environment |
source and dependency compile |
upload or behavior |
| Target |
serial, meter, scope, photo |
observed hardware behavior |
field reliability unless loaded |
| System |
integrated load/failure case |
requirement under scenario |
future deployment safety |
Anti-rationalization
| Shortcut |
Response |
| "The unit test passed." |
Keep all physical and system stages open. |
| "Wokwi matches the board." |
List what the model omits and verify those items on hardware. |
| "The sketch compiled." |
Require upload identity and target observations separately. |
| "The photo proves it works." |
Require board identity, measurement context, and observed result. |
| "Mark it done and test later." |
Keep the loop item blocked or needs-review until evidence exists. |
Verification
- Every requirement maps to a test, proof stage, and artifact path.
- Host/simulation/build/target/system results are labeled separately.
- Physical-only steps emit the concrete
Physical gate format from
embedded-project-loop.
- Failed and unverified cases remain visible in the report.
Shared output contract
Use the shared Arduino skill contract:
state assumptions, required tools and versions, implementation steps,
tests/evidence by proof stage, known limitations, and recovery/security notes.
1---2name: hardware-tdd3description: Use when planning tests for Arduino, ESP32, ESP32-S3, Pico, or Pico W firmware; deciding what can run off-target; using Wokwi or simulation; writing host fakes; or accepting a physical hardware feature without confusing compile proof with system proof.4---5
6# Hardware TDD
7
8Build the test ladder before claiming a feature is complete. Pure behavior can
9often be tested off-target; voltage, pin mux, timing under load, and physical
10assembly still require target evidence.
11
12## Intake
13
14Record exact board/revision, framework/toolchain, hardware invariants, safety
15inhibits, simulator model, available instruments, test fixtures, and the proof
16stage required by the user.
17
18## Process
19
201. Turn requirements into observable behavior and safety invariants.
212. Write host tests for pure C/C++ logic using fakes for time, serial, sensors,
22 and actuators. Keep hardware adapters thin.
233. Use Wokwi or another simulator only for peripherals and timing that its model
24 actually represents; record model limitations.
254. Run an exact-board compile and static checks with the selected toolchain.
265. Create a one-change target checklist: power-off continuity, controlled
27 power-up, input observation, output inhibit, reset/recovery, and logs.
286. Ask a physical gate for measurements, photos, or serial output. Do not infer
29 target success from a host test or compile log.
307. Record failures as evidence and keep the next test bounded.
31
32## Test matrix
33
34| Layer | Example | Proves | Does not prove |
35|---|---|---|---|
36| Host | debounce/state/packet parser | deterministic logic | pin voltage or wiring |
37| Simulation | modeled sensor/LED/UART | modeled interactions | regulator, clone, EMI, thermal behavior |
38| Build | exact FQBN/environment | source and dependency compile | upload or behavior |
39| Target | serial, meter, scope, photo | observed hardware behavior | field reliability unless loaded |
40| System | integrated load/failure case | requirement under scenario | future deployment safety |
41
42## Anti-rationalization
43
44| Shortcut | Response |
45|---|---|
46| "The unit test passed." | Keep all physical and system stages open. |
47| "Wokwi matches the board." | List what the model omits and verify those items on hardware. |
48| "The sketch compiled." | Require upload identity and target observations separately. |
49| "The photo proves it works." | Require board identity, measurement context, and observed result. |
50| "Mark it done and test later." | Keep the loop item blocked or `needs-review` until evidence exists. |
51
52## Verification
53
54- Every requirement maps to a test, proof stage, and artifact path.
55- Host/simulation/build/target/system results are labeled separately.
56- Physical-only steps emit the concrete `Physical gate` format from
57 `embedded-project-loop`.
58- Failed and unverified cases remain visible in the report.
59
60## Shared output contract
61
62Use [the shared Arduino skill contract](../../docs/arduino-skill-contract.md):
63state assumptions, required tools and versions, implementation steps,
64tests/evidence by proof stage, known limitations, and recovery/security notes.