How to make Cargo tests for local dependencies?

I am working on a project split into several mailboxes. A top-level box (application) requires two other boxes (libraries) as dependencies. Running cargo test in a top-level box builds dependencies and runs tests for a top-level box, but it does not run tests for the other two boxes. Is there a way to configure cargo test to run tests in all three boxes?

Thanks!

+5
source share
1 answer

You can pass the -p option to force Cargo to run dependency tests.

So, if your box is called sublib , you can run its tests using:

 cargo test -p sublib 

From cargo test --help :

-p SPEC, --package SPEC Package for running tests for

If the -package argument is given, then SPEC is the package identifier specification that indicates which package should be tested. If this is not specified, then the current package is tested. For more information about SPEC and its format, see the cargo help pkgid .

+6
source

Source: https://habr.com/ru/post/1212985/


All Articles