How to use objects in a sub module in tests?

I've got a project which is organized as follows:
workspace

  • project A
    -- src
    --- lib.rs
    -- tests
    --- common
    ---- a.rs
    ---- b.rs
    ---- mod.rs
    --- test_a.rs

mod.rs contains:
pub mod a;
pub mod b;

Now I have a function in file a.rs. I want to use it in file b.rs. How can I do this?

You should be able to reference public items in module a with super::a::whatever (from b) or crate::common::a::whatever (from anywhere in the tests, as long as the test file includes the common module)

I've tried super. But I get:
Could not find 'a' in 'super'

I've also tried crate. But I get:
Could not find 'a' in 'common'

I confirmed that it worked for me on rustc 1.65.0. The only way I can replicate that error is if I remove the mod a; from the mod.rs file.

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.