Warning
This post was published 58 days ago. The information described in this article may have changed.
Hello,
I am reading the Rust book How to Write Tests - The Rust Programming Language
and have this directory structure for a project named hello_cargo.
I get a compilation error that I wrote as comment above the code line. It cannot resolve the project name but this is what the Rust book does for the integration test, too.
Can someone explain why this does not work?
Test Organization - The Rust Programming Language
src/
- main.rs
- module1/
-- mod.rs
-- submodule1/
--- mod.rs
- module2/
-- mod.rs
- lib.rs
tests/
- integration_test.rs
// test/integration_test.rs
// compiler error:
// failed to resolve: use of unresolved module or unlinked crate `hello_cargo`
use hello_cargo::{module1, module2, module2::submodule1};
#[test]
fn testmain() {
assert_eq!(main::module1::mod1string(), "mod1string");
assert_eq!(main::module2::mod2string(), "mod2string");
assert_eq!(main::module1::submodule1::mod1string(), "submod1string");
//assert_eq!(main1::main1test(), "main1test");
}
6 posts - 2 participants
🏷️ rust_feed