Module scenario

Module scenario 

Source
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

  1. File Location: load() reads from {CARGO_MANIFEST_DIR}/res/scenarios/{id}.json
  2. JSON Parsing: Deserializes the file into a Scenario struct
  3. Error Handling: Returns anyhow::Error if file doesn’t exist or is malformed

§Save Process

  1. Atomic Write: Uses temporary file + rename for atomic operations
  2. Directory Creation: Automatically creates res/scenarios/ if needed
  3. JSON Format: Pretty-prints JSON for human readability
  4. Temporary Files: .tmp.{scenario_id}.json during 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 🔒

Structs§

Scenario
ScenarioId
ScenarioInfo

Enums§

ListenerNode
ScenarioStep

Functions§

event_details