Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
E

embedded-test

> 测试质量
Open source

A test harness and runner for embedded devices

180 stars0 likes2 views
WebsiteGitHub

About

A test harness and runner for embedded devices

Embedded Test

The embedded-test library provides a test harness for embedded systems (riscv, arm and xtensa). Use this library on the target together with probe-rs on the host to run unit + integration tests on your embedded device.

probe-rs together with embedded-test provide a (libtest compatible) test runner, which will:

  1. Read information about the available tests directly from the ELF file
  2. Flash all the tests to the device in one go (via the probe-rs run command)
  3. In turn for each testcase:
    • Reset the device
    • Signal to the device (via semihosting SYS_GET_CMDLINE) which test to run
    • Wait for the device to signal that the test completed successfully or with error (via semihosting SYS_EXIT)
  4. Report the results

Since the test runner (probe-rs run) is libtest compatible ( using libtest-mimic), you can use intellij or vscode to run individual tests with the click of a button.

Features

  • Runs each test case individually, and resets the device between each test case
  • Supports an init function which will be called before each test case and can pass state to the test cases
  • Supports async test and init functions (needs feature embassy)
  • Support #[should_panic], #[ignore] and #[timeout()] attributes for each test case

Usage

Add the following to your Cargo.toml:

toml
[dependencies]
embedded-test = { version = "0.7.0" }

[lib]
harness = false # Important: As we bring our own test harness for all tests

[[test]]
name = "example_integration_test"
harness = false

[[bin]]
name = "example_binary"
test = false # Unless you want to add unit tests to the binary

Want to move embedded-test to [dev-dependencies]? Look at embedded-test-linker-script.

Install the runner on your system:

bash
cargo install probe-rs-tools

Setup probe-rs as the runner in your .cargo/config.toml. For example:

toml
[target.thumbv7em-none-eabihf]
runner = "probe-rs run --chip STM32F767ZITx"
# `probe-rs run` will autodetect whether the elf to flash is a normal firmware or a test binary

Add the following to your build.rs file:

rust
fn main() {
    println!("cargo::rustc-link-arg=-Tembedded-test.x");
    println!("cargo::rustc-check-cfg=cfg(rust_analyzer)");
}

Then you can run your tests with cargo test or use the button in vscode/intellij.

Having trouble setting up? Checkout out the FAQ and common Errors Wiki page.

Example Test (e.g. tests/example_test.rs)

Check the example folder for a complete example project for stm32/esp32.

…

Configuration features

Feature Default? Description
panic-handler Yes Defines a panic-handler which will invoke semihosting::process::abort() on panic
defmt No Prints testcase exit result to defmt. You'll need to setup your defmt #[global_logger] yourself (e.g. #[embedded_test::setup] fn setup() {rtt_target::rtt_init_defmt!()}) .
log No Prints testcase exit result to log. You'll need to setup your logging sink yourself (e.g. #[embedded_test::setup] fn setup() {rtt_target::rtt_init_log!()})
embassy-09 or embassy-010 No Enables async test and init functions. Note: You need to enable at least one executor feature on the embassy-executor crate unless you are using the external-executor feature.
external-executor No Allows you to bring your own embassy executor which you need to pass to the #[tests] macro (e.g. #[embedded_test::tests(executor = esp_hal::embassy::executor::thread::Executor::new())])
xtensa-semihosting No Enables semihosting for xtensa targets.
ariel-os-09 or ariel-os-010 No Enables Ariel OS integration.

Please also note the doc for the Attribute Macro embedded_test::tests.

License

Licensed under either of:

  • Apache License, Version 2.0
  • MIT license

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustembeddedrusttesting

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category测试质量
PricingOpen source

> Related tools

J
Jest
JavaScript 测试框架
P
Playwright
现代端到端测试框架
E
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.