Expand description
§Scenario Management
This module provides functionality for managing test scenarios, including loading, saving, and executing deterministic test sequences.
§How Scenarios Work
§Storage Format
Scenarios are stored as JSON files in the res/scenarios/ directory relative
to the testing crate. Each scenario file contains:
- ScenarioInfo: Metadata (ID, description, parent relationships, node configs)
- ScenarioSteps: Ordered sequence of test actions to execute
§Load Process
- File Location:
load()reads from{CARGO_MANIFEST_DIR}/res/scenarios/{id}.json - JSON Parsing: Deserializes the file into a
Scenariostruct - Error Handling: Returns
anyhow::Errorif file doesn’t exist or is malformed
§Save Process
- Atomic Write: Uses temporary file + rename for atomic operations
- Directory Creation: Automatically creates
res/scenarios/if needed - JSON Format: Pretty-prints JSON for human readability
- Temporary Files:
.tmp.{scenario_id}.jsonduring write, renamed on success
§Scenario Inheritance
Scenarios can have parent-child relationships where child scenarios inherit setup steps from their parents, enabling composition and reuse.
For usage examples, see the testing documentation.
Modules§
- event_
details 🔒 - id 🔒
- step 🔒