model-based-testing
Model-Based Testing
Test state machines systematically — don't guess at valid transitions.
State machines are everywhere: workflow states, lifecycle management, game turns, circuit breakers. Most bugs come from invalid transitions being allowed or valid transitions being blocked. This skill teaches you to systematically test ALL state pairs, not just the happy path.
When to use: Any code with named states, lifecycles (initializing → ready → stopping), workflow progressions (draft → review → published), turn-based systems, circuit breakers, or XState machines.
When not to use: Stateless functions, simple CRUD, UI rendering without state machines, pure data transformations.
Model-Based vs Pairwise
Model-based derives which state transitions to test. Pairwise testing selects which input combinations to test. Different questions, different tools:
| Your system has... | Use | Example |
|---|---|---|
| Named states with transitions between them | Model-based | draft → review → published workflow |
| Independent parameters with discrete values | Pairwise | retry count × timeout × backoff × status |
| State machine guards with 5+ boolean inputs | Both | Model-based finds the guards, pairwise covers the flag combos |