Embedded testing

Hi

I am starting with embedded rust. I've been poking around on my repo with cargo test. I've encountered a weird problem. When I run cargo test, which should run tests on host OS, I get:

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Enev though I have one test which should be ran. Any one have any idea why ? I've added all required macros.

1 Like

You have:

#![cfg_attr(not(test), no_std)]
#![cfg_attr(not(test), no_main)]
#![cfg(not(test))]
extern crate panic_halt;

The #![cfg(not(test))] inner attribute is applying to your entire file, making it effectively empty when tested. Perhaps you meant it to be an outer attribute #[cfg(not(test))] (with no !) applying to extern crate panic_halt; only.

2 Likes

Yep that was the issue. Thx. Newbie problem :smiley:

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.