Hi, I have a test file under sub-dir of tests (tests\backtrack) and cargo test cannot find it. Any suggestion? Thanks!
The Cargo documentation says:
If a binary, example, bench, or integration test consists of multiple source files, place a
main.rsfile along with the extra modules within a subdirectory of thesrc/bin,examples,benches, ortestsdirectory. The name of the executable will be the directory name.
So a function marked with #[test] in tests/backtrack/test_backtrack.rs won't be automatically run by cargo test, unlike if you put the same function in tests/test_backtrack.rs. Instead, Cargo assumes that tests/backtrack/test_backtrack.rs contains a module that will be pulled in by some other test, but since there are no mod statements in your code, it never will be. If you want that #[test] function to be run, but still want the .rs file to be in its own directory under tests/, you should rename the file to tests/backtrack/main.rs, and Cargo will do the desired thing.
Thank you!
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.
