2025-12-01 12:48:39 +01:00
|
|
|
use async_trait::async_trait;
|
|
|
|
|
|
2026-02-02 07:19:22 +01:00
|
|
|
use super::{Application, DynError, RunContext, runtime::context::RunMetrics};
|
2025-12-01 12:48:39 +01:00
|
|
|
|
|
|
|
|
#[async_trait]
|
|
|
|
|
/// Defines a check evaluated during or after a scenario run.
|
2026-02-02 07:19:22 +01:00
|
|
|
pub trait Expectation<E: Application>: Send + Sync {
|
2025-12-01 12:48:39 +01:00
|
|
|
fn name(&self) -> &str;
|
|
|
|
|
|
|
|
|
|
fn init(
|
|
|
|
|
&mut self,
|
2026-02-02 07:19:22 +01:00
|
|
|
_descriptors: &E::Deployment,
|
2025-12-01 12:48:39 +01:00
|
|
|
_run_metrics: &RunMetrics,
|
|
|
|
|
) -> Result<(), DynError> {
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-02 07:19:22 +01:00
|
|
|
async fn start_capture(&mut self, _ctx: &RunContext<E>) -> Result<(), DynError> {
|
2025-12-01 12:48:39 +01:00
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-21 15:28:08 +01:00
|
|
|
/// Optional periodic check used by fail-fast expectation mode.
|
|
|
|
|
///
|
|
|
|
|
/// Default is a no-op so existing expectations stay end-of-run only.
|
|
|
|
|
async fn check_during_capture(&mut self, _ctx: &RunContext<E>) -> Result<(), DynError> {
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-02 07:19:22 +01:00
|
|
|
async fn evaluate(&mut self, ctx: &RunContext<E>) -> Result<(), DynError>;
|
2025-12-01 12:48:39 +01:00
|
|
|
}
|