Skip to main content

eventcore_testing/
lib.rs

1//! Testing utilities for EventCore backends and commands.
2//!
3//! This crate provides helpers for verifying that `EventStore` implementations
4//! satisfy their behavioral contracts, injecting failures for chaos and retry
5//! testing, and writing readable Given-When-Then command tests.
6//!
7//! # Modules
8//!
9//! - [`contract`] — Behavioral contract tests via the `backend_contract_tests!`
10//!   macro. Run these against any `EventStore` implementation to verify it
11//!   upholds all required guarantees (optimistic concurrency, atomicity,
12//!   ordering, etc.).
13//!
14//! - [`chaos`] — [`ChaosEventStore`]: wraps an `EventStore` and injects
15//!   probabilistic failures. Use for chaos testing to verify that command
16//!   retry logic handles transient errors correctly.
17//!
18//! - [`deterministic`] — [`DeterministicConflictStore`]: injects predictable
19//!   stream-version conflicts on the first write attempt, then succeeds on
20//!   retry. Use for deterministic testing of the automatic retry path in
21//!   `eventcore::execute()`.
22//!
23//! - [`event_collector`] — [`EventCollector`]: a `Projector` implementation
24//!   that accumulates every event it sees into a `Vec`. Use in assertions to
25//!   confirm which events were written to the store.
26//!
27//! - [`scenario`] — [`TestScenario`]: a Given-When-Then builder for command
28//!   tests. Seed the store with prior events (Given), execute a command
29//!   (When), and assert on the resulting events or error (Then).
30
31pub mod chaos;
32pub mod contract;
33pub mod deterministic;
34pub mod event_collector;
35pub mod scenario;
36
37pub use chaos::*;
38pub use contract::*;
39pub use deterministic::*;
40pub use event_collector::*;
41pub use scenario::*;