Add ability to ignore tests at runtime. · Issue #68007 · rust-lang/rust (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@XAMPPRocky

Description

@XAMPPRocky

For medium–large scale projects, or projects that have a lot of integrations with third party services. It would nice to be able to ignore tests based on the environment the tests are being run in. One example would be to run tests if an environment variable is present.

You can workaround this with something like the following, however the output of the test is ok and not ignored, misleading the user that the test was successful.

#[test] fn foo() { if env::var("FOO").is_none() { return; } let foo = env::var("FOO").unwrap(); }