embedded-test
FreeA versatile test harness for embedded devices, supporting unit tests, integration tests, async tests, and more.
FreeFree tier
About embedded-test
The embedded-test library provides a test harness for embedded systems (RISC-V, ARM, and Xtensa). It is used together with probe-rs on the host to run unit and integration tests on embedded devices. The test runner reads test information directly from the ELF file, flashes all tests in one go, and then runs each test individually by resetting the device between tests. It supports init functions that can pass state to tests, async tests (with the embassy feature), and attributes like #[should_panic], #[ignore], and #[timeout]. The runner is libtest compatible, allowing IDE integration in IntelliJ and VS Code.
Key Features
Runs each test case individually with device reset between tests
Supports async test and init functions (requires embassy feature)
Supports init function to pass state to test cases
Supports #[should_panic], #[ignore], and #[timeout(seconds)] attributes
Libtest compatible, enabling IDE integration (IntelliJ, VS Code)
Flashes all tests to device in one go via probe-rs run
Supports RISC-V, ARM, and Xtensa architectures
Pros & Cons
Pros
- Provides test isolation by resetting device between each test
- Allows writing async tests with embassy support
- Integrates with IDEs for one-click test execution
- Efficiently flashes all tests at once and runs them sequentially
- Open source and free to use
Cons
- Requires a hardware debug probe compatible with probe-rs
- Limited to supported architectures (RISC-V, ARM, Xtensa)
- Setup requires specific configuration (Cargo files, linker script, build.rs)
- Relies on semihosting for communication between target and host
Best For
Running unit tests on embedded devicesRunning integration tests for firmwareTest-driven development for embedded Rust projectsAutomated testing in CI with probe-rs
FAQ
How do I set up embedded-test in my project?
Add embedded-test as a dependency in Cargo.toml, set harness = false for test targets, install probe-rs-tools, configure the runner in .cargo/config.toml, and add a build.rs file with linker script linking. Then run tests with cargo test.
Which architectures are supported?
Embedded-test supports RISC-V, ARM, and Xtensa architectures.
Can I run async tests?
Yes, if you enable the 'embassy' feature, you can use async test and init functions.