I try to make the following file structure work:
-- lib1 -- src -- file1.rs
-- lib2 -- src -- file1.rs
-- tests -- test-lib1.
how can i do this?
Or is this a bad style?
Do i have to use the #[path] attribute?
thanks for your effort
The Tokio repository does this for some of its tests. You can find the tests in the
tokio has their tests in the "standard" tests directory next to the src directory.
Cargo searches for that by default, so that doesn't help me in any way and was not my question
I misunderstood what you were asking for.
It's possible to have a
Cargo.toml with a
tests/ folder in the project root together with the sub-library folders. However, this would associate the tests with a project defined in the root folder, and I'm pretty sure that you would need a
src/ folder in the root too.
Another option that I think would work is to add the following to
lib1/Cargo.toml for each test:
name = "lib1-tests"
path = "../tests/test-lib1.rs"
However this approach requires that you list every file in the
tests folder separately.
Thank you, this is a fine solution for me
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.