Enable futures in [profile.test]

Can cargo test enable crate to directly enble some features?

[profile.test]
required-features = ["for-test"]

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.

I'm not talking about the use of cargo, the purpose of this is to discuss whether features can be enabled in profiles. You're right, we should try to make sure that we're testing the same code, but now there's a scenario where I want to provide testing features in crate, like not starting the actual backend dependency, but a stub. (Rust doesn't have tools like GitHub - mockito/mockito: Most popular Mocking framework for unit tests written in Java, and mockall doesn't meet my needs well.)

@ehuss Usage issues I discussed earlier at https://users.rust-lang.org/ How to reference the test of another crate in the current crate - #2 by silence-coding - help - The Rust Programming Language Forum