Skip to content

HerrMuellerluedenscheid/needs_env_var

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Needs Environment Variable

Crates.io Version

Early return from a test (or method in general) if an environment variable is undefined or does not match a specific value.

Example

some_test will be skipped if MY_ENVIRONMENT_VARIABLE is not defined (example 1) or does not match 1 (examples 2).

use needs_env_var::*;

// Test will be skipped if `MY_ENVIRONMENT_VARIABLE` is not defined
#[needs_env_var(MY_ENVIRONMENT_VARIABLE)]
#[test]
fn some_test() {
    // ...
}

// or if does not match `1`
#[needs_env_var(MY_ENVIRONMENT_VARIABLE=1)]
#[test]
fn some_test() {
    // ...
}

About

Rust macro to skip e.g. tests if environment variable is undefined

Topics

Resources

License

Stars

Watchers

Forks

Languages