Created
August 11, 2021 11:30
-
-
Save cuongld2/87c3770a7590b2ed323042c2ae2fa62e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use rstest::*; | |
use std::sync::Once; | |
static INIT: Once = Once::new(); | |
#[fixture] | |
pub fn setup() -> () { | |
INIT.call_once(|| { | |
println!("Hello, world!"); | |
// initialization code here | |
}); | |
} | |
#[fixture] | |
pub fn fixture() -> u32 { 42 } | |
#[rstest] | |
fn should_success(fixture: u32,setup: ()) { | |
assert_eq!(fixture, 42); | |
} | |
#[rstest] | |
fn should_fail(fixture: u32,setup: ()) { | |
assert_ne!(fixture, 42); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment