Skip to content

Instantly share code, notes, and snippets.

@cuongld2
Created August 11, 2021 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cuongld2/87c3770a7590b2ed323042c2ae2fa62e to your computer and use it in GitHub Desktop.
Save cuongld2/87c3770a7590b2ed323042c2ae2fa62e to your computer and use it in GitHub Desktop.
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