I have a following folder structure,
.
├── utils/
│ ├── helpers.rs
│ └── lib.rs
├── tests/
│ └── helpers.rs
└── Cargo.toml
lib.rs
just includes helpers.rs
,
mod helpers;
So how do use utils::helpers
inside tests/helpers.rs
?
The tests
folder contains your integration tests. Those tests may only use the public interface of your library, and not test internals that are hidden to a user of your library.
If you want your users to use utils::helpers
, then make sure that it is pub
lic and write integration tests from the downstream developers perspective. However, if you only want to write unit tests (which is much more likely), then add them in the helpers
module itself.
See "Test Organization" in The Rust Programming Language for more information.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.