Embedded testing in one sentence
Embedded testing is the process of checking that an embedded system’s software (its firmware) and its hardware work correctly, both separately and together, under the real conditions the device will face.
An embedded system is a small computer built into a larger product, such as the controller in a washing machine, a car’s engine control unit or a fitness tracker. Testing it means more than checking that the code gives the right answers. It also means checking that the device responds in time, handles its sensors and inputs properly, behaves well when something goes wrong, and keeps running for as long as it is expected to.
What gets tested
The firmware
The firmware is the program running on the device’s microcontroller or processor. Testing it covers the usual software questions: does each function return the right result, are edge cases handled, does the logic follow the requirements? Much of this can be done on a desktop computer, with the hardware replaced by simple software stand-ins.
The hardware
The hardware side includes the circuit board, power supply, sensors, actuators and communication links. Hardware testing checks things like correct voltages, signal quality, behaviour across the operating temperature range and, for many products, electromagnetic compatibility.
The two together
Many of the hardest bugs only appear when the firmware runs on the real board: a sensor that needs more time to start up than the datasheet suggested, an interrupt that arrives at an awkward moment, or a power dip during a flash write. Testing hardware and software together is what separates embedded testing from most other kinds of software testing.
How embedded testing differs from ordinary software testing
| Typical application software testing | Embedded testing | |
|---|---|---|
| What is tested | Software only | Software, hardware and their interaction |
| Where it runs | Desktop, server, browser or phone | A dedicated device, often with limited memory and no screen |
| Timing | Usually “fast enough” is fine | Often must meet strict deadlines (real-time) |
| Inputs | Keyboard, network, files | Sensors, buttons, buses, radio, power events |
| Access to the target | Plentiful | Often limited prototypes, or hardware that doesn’t exist yet |
| Cost of a field bug | Ship an update | May need a recall, or updates may be impossible |
| Safety | Usually low risk | Can be safety-critical (medical, automotive, industrial) |
The main levels of embedded testing
Most teams test at several levels, building up from small pieces to the whole product:
- Static analysis and code review. Tools and colleagues check the source code before it runs, looking for defects and coding-standard violations.
- Unit testing. Individual functions or modules are tested in isolation, usually on a host PC, with hardware replaced by mocks or stubs.
- Integration testing. Modules are combined to check they work together, first software with software, then software with the real hardware.
- Hardware-in-the-loop (HIL) testing. The real device is connected to a test rig that simulates the outside world, such as sensor signals, motor loads or network traffic, so it can be tested repeatably and safely.
- System testing and validation. The finished product is tested against its requirements, including environmental conditions and, where needed, regulatory compliance.
Our full guide to testing and validating embedded software explains each level in more depth, including integration strategies and code coverage.
A simple example: testing a thermostat controller
Imagine a basic thermostat that reads a temperature sensor and switches a heater on and off.
- Unit test: on a PC, feed the control function a series of fake temperatures and check it turns the heater on below the set point and off above it, with the right amount of hysteresis so it doesn’t switch rapidly back and forth.
- Integration test: run the firmware on the real board with the real sensor and check the reading matches a reference thermometer, and that the relay output actually switches.
- HIL test: connect the board to a rig that simulates the sensor and the room’s temperature response, then run scenarios such as a sensor fault or a power cut, and check the thermostat fails safe.
- System test: install the finished unit in a test room or climate chamber and confirm it holds the temperature within the required band over a long run.
Each level catches different problems. A logic error is cheapest to find in the unit test; a noisy sensor line will only show up on real hardware.
Why embedded testing is hard
Competitor guides and practitioners tend to agree on the same set of challenges:
- Hardware dependency. The target hardware may be scarce, expensive or still being designed while the firmware is written.
- Simulators aren’t perfect. Emulators and simulators help, but they may not reproduce real timing, noise or analog behaviour exactly.
- Hard-to-reproduce defects. Faults that depend on timing, temperature or a rare sequence of events can be very difficult to recreate on demand.
- Hardware or software? When something fails, it isn’t always obvious whether the cause is in the code, the circuit or the interaction between them.
- Limited visibility. Many devices have no screen and little spare memory for logging, so engineers rely on debug probes, serial output and logic analysers.
- Updates and long lifetimes. Devices may stay in service for years, and every firmware update needs retesting.
Common tools and techniques
- Unit test frameworks for C and C++ such as Unity, CppUTest and GoogleTest.
- Mocks and stubs that stand in for hardware drivers during host-based tests.
- Debug probes using JTAG or SWD to step through code on the target.
- Oscilloscopes and logic analysers to see what signals are actually doing.
- HIL rigs that drive and measure the device’s inputs and outputs automatically.
- Continuous integration that runs tests on every code change, sometimes including tests on real boards.
- Code coverage tools, which are especially important in safety-critical work where standards may require specific coverage levels.
Where to learn more
Embedded testing sits within the wider embedded system design flow, and it overlaps heavily with the integration stage covered in our article on hardware-software co-design and integration. For how testing fits into the overall process model, see the embedded system development life cycle.