ABT Foundations • Module 5

State Management in ABT

Handling application state across test actions

Module 5 illustration

"Dear Marilyn,

My tests pass when run individually but fail when run together. I think they're interfering with each other somehow. How do I fix this?

— Randomly Failing"

Marilyn Responds:

You've encountered the most insidious bug in test automation: shared state. When tests share state—whether in the application, the database, or the test framework—they become unpredictable.

ABT addresses this through explicit state management. Every action declares what state it needs and what state it produces.

Tests become deterministic because state is controlled, not accidental.

State Contracts

Every action has a state contract:

  • Preconditions — What state must exist before the action runs
  • Postconditions — What state the action guarantees after it completes
  • Invariants — What state must remain unchanged

When contracts are explicit, test isolation becomes automatic.

Quick Check: Module 5

Question: Why do tests fail when run together but pass individually?

a) The tests are too slow

b) Shared state between tests causes interference

c) The test framework has bugs

d) Tests should never be run together

(Answer: b — Shared state is the most common cause of flaky tests. Explicit state management prevents this.)