Available on crate feature
test-harness only.Expand description
Test harness for observing and asserting on event flow.
Enable with the test-harness feature:
[dev-dependencies]
maiko = { version = "0.2", features = ["test-harness"] }§Example
ⓘ
use maiko::testing::Harness;
// Create harness BEFORE starting supervisor
let mut test = Harness::new(&mut supervisor).await;
supervisor.start().await?;
test.record().await;
let id = test.send_as(&producer, MyEvent::Data(42)).await?;
test.settle().await;
// Query using spies
assert!(test.event(id).was_delivered_to(&consumer));
assert_eq!(1, test.actor(&consumer).events_received());
// Or use EventQuery for complex queries
let orders = test.events()
.sent_by(&trader)
.matching_event(|e| matches!(e, MyEvent::Order(_)))
.count();
// Or trace event propagation with EventChain
let chain = test.chain(id);
assert!(chain.actors().exact(&[&producer, &processor, &writer])); // exact path
assert!(chain.actors().segment(&[&processor, &writer])); // contiguous sub-path
assert!(chain.actors().passes_through(&[&producer, &writer])); // gaps allowed
assert!(chain.events().segment(&["Input", "Processed", "Output"]));§Warning
Do not use in production. See Harness documentation for details.
Structs§
- Actor
Spy - A spy for observing events from the perspective of a specific actor.
- Actor
Trace - Actor trace view for querying which actors were visited by the chain.
- Event
Chain - A chain of events originating from a single root event.
- Event
Entry - A record of an event delivery from one actor to another.
- Event
Matcher - A matcher for filtering events in chain queries.
- Event
Query - A composable query builder for filtering and inspecting recorded events.
- Event
Spy - A spy for observing the delivery and effects of a specific event.
- Event
Trace - Event trace view for querying the sequence of events in the chain.
- Expectation
- A condition-based settle builder.
- Harness
- Test harness for observing and asserting on event flow in a Maiko system.
- Topic
Spy - A spy for observing events on a specific topic.