I'm working on a project split across multiple crates. The top-level crate (the app) requires the two other crates (libraries) as dependencies. Running cargo test
in the top-level crate builds the dependencies and runs tests for the top-level crate, but it doesn't run tests for the two other crates. Is there a way to configure cargo test
so that it will run tests in all three crates?
Thanks!
You can pass the -p
parameter to make Cargo run the tests of a dependency.
So, if your crate is called sublib
, you can run its tests using:
cargo test -p sublib
From cargo test --help
:
-p SPEC, --package SPEC Package to run tests for
If the --package argument is given, then SPEC is a package id specification which indicates which package should be tested. If it is not given, then the current package is tested. For more information on SPEC and its format, see the
cargo help pkgid
command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With