Cannot Find Macro in This Scope

I actually post this to see if I do this correctly. I kinda understand how macros work but importing them is a pain.

Whatever, so there's a great package called galvanic-test. I added it to my Cargo file. I used extern crate at the root of my crate. I imported test_suite macro in my chunk submodule and used it accordingly.

Yet cargo build or cargo test panics:

error: cannot find macro `test_suite` in this scope
   --> src/
138 | test_suite! {
    | ^^^^^^^^^^

I do not understand. I think my steps are correct right?


  • cargo 1.40.0 (bc8e4c8be 2019-11-22)
  • rustc 1.40.0 (73528e339 2019-12-16)
use galvanic_test::test_suite;

Means that test_suite! is only imported when building tests. But the usage of test_suite! is for all builds. The test_suite! usage needs to have a #[cfg(test)] infront of it as well.

test_suite! {
1 Like

Oh yeah, I'm really surprised I haven't seen that. Thanks.