Separating Unit Test Feature Flags


Hi! Is it possible to only use feature flags when running unit tests?

I would like to use some features such as required for futures-await to make writing tests a little more bearable, however it is not a requirement for the library as a whole.


There’s no special support for features in tests, but regular feature switch like cargo test --features=foo works.

You could add a foo feature to your crate, make it depend on futures-await, and mark tests using it with #[cfg(feature="foo")].