How to Test Embedded Rust Code

Run cargo test for standard projects or mdbook test with library paths for book-based embedded Rust code.

Run cargo test in your project directory to execute all unit and integration tests for your embedded Rust code. For mdbook projects, you must first build external dependencies and then run mdbook test with the correct library path.

cargo test

For mdbook projects with external crates like trpl:

cd packages/trpl && cargo build
mdbook test --library-path packages/trpl/target/debug/deps