pub struct RetryErrors<E> { /* private fields */ }
Expand description

Test decorator that retries a wrapped test a certain number of times only if an error matches the specified predicate.

Constructed using Retry::on_error().

§Examples

use test_casing::{decorate, decorators::{Retry, RetryErrors}};
use std::error::Error;

const RETRY: RetryErrors<Box<dyn Error>> = Retry::times(3)
    .on_error(|err| err.to_string().contains("retry please"));

#[test]
#[decorate(RETRY)]
fn test_with_retries() -> Result<(), Box<dyn Error>> {
    // test logic
}

Trait Implementations§

source§

impl<E> Debug for RetryErrors<E>

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<E: Display + 'static> DecorateTest<Result<(), E>> for RetryErrors<E>

source§

fn decorate_and_test<F>(&self, test_fn: F) -> Result<(), E>
where F: TestFn<Result<(), E>>,

Decorates the provided test function and runs the test.

Auto Trait Implementations§

§

impl<E> RefUnwindSafe for RetryErrors<E>

§

impl<E> Send for RetryErrors<E>

§

impl<E> Sync for RetryErrors<E>

§

impl<E> Unpin for RetryErrors<E>

§

impl<E> UnwindSafe for RetryErrors<E>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.