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§
Sourcefn check_now(&self, harness: &H, node: &KdlNode) -> Result<bool, TestErrorCase>
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.
Sourcefn wait_until(&self, harness: &H, node: &KdlNode) -> Result<bool, TestErrorCase>
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.
Sourcefn clone_box(&self) -> Box<dyn TestCondition<H>>
fn clone_box(&self) -> Box<dyn TestCondition<H>>
Clone the condition