How to use State Transition Generator
- Write one transition per line; the first state is the initial state.
- Choose 0-switch or 1-switch coverage and whether to include invalid-transition tests.
- Generate to get the state table, Mermaid diagram and test cases.
State Transition Generator features
- Transitions as "State --event--> State" with optional guards
- State × event table showing valid targets and invalid combinations
- 0-switch and 1-switch coverage test cases
- Negative tests for every invalid transition
- Unreachable-state and missing-final-state warnings
- Mermaid stateDiagram-v2 text for documentation
State Transition Generator example
Order workflow
Input:
New --pay--> Paid
Paid --ship--> Shipped
Shipped --deliver--> Delivered
New --cancel--> CancelledOutput:
ST-001 New —pay→ Paid positive
ST-005 New —pay→ Paid —ship→ Shipped positive (1-switch)
ST-008 Invalid: "ship" while in New negative
stateDiagram-v2
[*] --> New
New --> Paid: pay
Paid --> Shipped: shipFrequently asked questions about State Transition Generator
How do I write transitions?
One per line as "State --event--> State". Guards go in brackets ("Delivered --return [within 14 days]--> Returned"). The first state mentioned is the initial state.
What is 0-switch and 1-switch coverage?
0-switch tests every single transition. 1-switch tests every valid pair of consecutive transitions, which finds bugs that only show up after a particular sequence.
What are invalid-transition tests?
For every state × event combination without a defined transition, a negative test checks the event is rejected and the state does not change — the most common source of workflow bugs.
What can I do with the Mermaid diagram?
Paste it into GitHub, GitLab, Notion, Obsidian or mermaid.live to render the state diagram for reviews and documentation.