Hacker News new | ask | show | jobs
by sgtnoodle 2277 days ago
I've found a lot of value in running unit tests on target hardware. For one thing, it means you can actually include peripheral drivers in the test. Also, as you said, embedded compilers tend to be more buggy than host compilers. I've actually found compiler bugs through embedded unit testing.
1 comments

Peripheral unit tests are best run off-target in my experience. We mock out all register accesses for host builds, then can write unit tests that validate we write registers in the right order, handle states that are in-spec but hard to get the real peripheral in to, etc. Things that may work a million times in a row on real hardware, but then regularly fail in the field on a few million devices.

Running them on-target is more of an integration test -- useful too, obviously, but gives a quite low level of assurance.

Yes, exactly. Once you're testing integration with hardware you're integration testing, not unit testing as it's not pure software dictating the outcome of the test.