pub struct Fickle { /* private fields */ }
Expand description
Retry a fickle test if it fails initially.
use fickle::Fickle;
// There is a 30% chance this test fails any 1 run. But since 3 retries are allowed (4 total
// runs), this is just a 0.3^4=0.81% chance that they *all* fail. So `Fickle` transforms this
// from a test that is problematically flaky to one that should rarely be an issue.
fn flaky() {
let fickle = Fickle::new(3, 1).unwrap();
let flakycode: fn() -> () = || {
if 0.7 < rand::random() {
panic!("number was too big!")
}
};
fickle.run(flakycode).unwrap()
}
Implementations§
Source§impl Fickle
impl Fickle
Sourcepub fn new(retries: usize, passes: usize) -> Result<Self, FickleError>
pub fn new(retries: usize, passes: usize) -> Result<Self, FickleError>
Specify the number of retries & number of required passes.
Sourcepub fn new_retries(retries: usize) -> Result<Self, FickleError>
pub fn new_retries(retries: usize) -> Result<Self, FickleError>
Specify the number of retries, while using the default number of passes (1).
Sourcepub fn new_passes(passes: usize) -> Result<Self, FickleError>
pub fn new_passes(passes: usize) -> Result<Self, FickleError>
Specify the number of passes, while using the default number of retries (1).
pub fn run<T, E: Display, P, Q: Debug>( &self, test: impl Test<T, E, P, Q>, ) -> Result<T, TooManyFailures<E, Q>>
Trait Implementations§
Source§impl Default for Fickle
By default, just 1 retry is attempted and 1 passing test run is required.
impl Default for Fickle
By default, just 1 retry is attempted and 1 passing test run is required.
impl Copy for Fickle
Auto Trait Implementations§
impl Freeze for Fickle
impl RefUnwindSafe for Fickle
impl Send for Fickle
impl Sync for Fickle
impl Unpin for Fickle
impl UnwindSafe for Fickle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more