I have some tests that I would like to ignore when using cargo test
(to enable offline development) and only run when explicitly passed a feature flag.
I know this can be done by using #[ignore]
and cargo test -- --ignored
, but I'd like to have other ignored tests for other reasons.
I have tried this:
#[test]
#[cfg_attr(not(feature = "online_tests"), ignore)]
fn get_github_sample() {
}
This is ignored when I run cargo test
as desired.
But I can't get it to run, and have tried:
cargo test --features "online_tests"
cargo test --all-features
But they continue to be ignored.
I then added the feature definition into my Cargo.toml
as per this page, but they continue to be ignored.
I am using workspaces in cargo. I tried adding the feature definition in both Cargo.toml
files, no difference.
Any ideas?
Aucun commentaire:
Enregistrer un commentaire