Trait TestCondition

Source
pub trait TestCondition<H>: 'static {
    // Required methods
    fn check_now(
        &self,
        harness: &H,
        node: &KdlNode,
    ) -> Result<bool, TestErrorCase>;
    fn wait_until(
        &self,
        harness: &H,
        node: &KdlNode,
    ) -> Result<bool, TestErrorCase>;
    fn clone_box(&self) -> Box<dyn TestCondition<H>>;
}
Expand description

A condition check for a given property

Conditions allow to check for anything you would find useful. For example, in a HTTP library, you can check that your cache contains a valid entry from a previous request.

Required Methods§

Source

fn check_now(&self, harness: &H, node: &KdlNode) -> Result<bool, TestErrorCase>

Run the check now, may or may not actually be implemented

This is only useful for non-transient properties. For example “is this connected”. It is not a way to check for events.

If the condition cannot properly support the concept of ‘checking now’ it is ok to simply return an error.

Source

fn wait_until(&self, harness: &H, node: &KdlNode) -> Result<bool, TestErrorCase>

Wait until a given condition evaluates to a meaningful value

Some properties of a system are not meaningful other than ‘that they happened’. This could be an event or some value changing.

If the condition cannot properly support the concept of ‘waiting until it has a value’, it is ok to simply return an error.

Source

fn clone_box(&self) -> Box<dyn TestCondition<H>>

Clone the condition

Trait Implementations§

Source§

impl<H: 'static> Clone for Box<dyn TestCondition<H>>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§

Source§

impl<H> TestCondition<H> for Condition<H>
where H: 'static,