How to run test under tests/folder


I have some test files in tests\folder, I don't know how can I run those test files.

I tried something like: cargo test --test .\tests\folder\test_file, they won't work.

Thanks in advance for your help.

Hi, when you make a folder inside the tests directory it's not part of the tests anymore.
You can make a file in tests and call the functions inside the folder though.
You can learn more about it in this chapter of the book.

You are right, I just tried cargo test, and the files under the folder cannot run.

Well, it's the answer that I don't want it to be, but looks like I have to accept it.

Thanks for the help.

If the extra work is worth breaking each test up you could always have separate crates for each section of functionality you are testing.

- tests
   - some_crate
   - // calls fns from some_crate
- Cargo.toml // imports some_crate as dev-dep

The Cargo.toml would have a line to import some_crate

some_crate = { path = "./tests/some_crate"}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.