If you want to enable the feature of a dependency while testing, you can place the feature in the dev-dependencies
table, like this:
[dependencies]
some-dependency = { path = "some-dependency" }
[dev-dependencies]
some-dependency = { path = "some-dependency", features = ["for-test"] }
I don't recommend doing this. I would suggest restructuring your crates so that test-specific needs are in a separate crate. When running tests, it is best for the code being tested to be the same as the non-test scenario.
For questions on how to use Cargo, I suggest using https://users.rust-lang.org/. This forum is for the discussion of the development of Rust itself.