File Structure Syntax
Complete syntax patterns for EventFlow file organization.
Basic File Structure
flow
machine: @machine_name
scenario: scenario name
given:
// setup
on :event from @actor (api)
// actions
// guards
// emit
expect:
// assertions
on :event from @actor
// ...
expect:
// scenario assertionsMachine Definition
flow
machine: @nameExamples:
flow
machine: @order
machine: @payment
machine: @customerSystem Definition
flow
system: system name
uses:
@machine1 from "./path/to/machine1.flow"
@machine2 from "./path/to/machine2.flow"
machine: @machine3
// Can also define inlineScenario Definition
flow
scenario: descriptive name
// optional given
given:
// setup
// event handlers
on :event from @actor (api)
// ...
// optional assertions
expect:
// ...Given Blocks
Scenario-Level
flow
scenario: name
given:
@actor is in state
$variable: type is value
collection contains itemsEvent-Level
flow
on :event from @actor (api)
given:
additional setupTable Data
flow
given:
cart contains:
| product | price | quantity |
| Laptop | 1200 | 1 |
| Mouse | 25 | 2 |Expect Blocks
Event-Level Assertions
flow
on :event from @actor (api)
// actions
expect:
= assertion1
= assertion2Scenario-Level Assertions
flow
scenario: name
on :event1 from @customer (api) ...
on :event2 ...
expect:
= final assertionsComments
flow
// Single line comment
/*
Multi-line
comment
*/
action // Inline commentIndentation
EventFlow uses indentation for nesting. Use consistent spaces (2 or 4):
flow
machine: @order // Level 0
scenario: checkout // Level 1
given: // Level 2
@customer is logged in // Level 3
on :checkout from @customer (api) // Level 2
? cart is valid // Level 3
order moves to #processing // Level 4
emit :request to @payment // Level 4
otherwise // Level 3
emit :error to @customer // Level 4
expect: // Level 2
= order is in #processing // Level 3