Skip to content

How it works

Arrange, act, assert. Set up the state, call the unit, verify the result. If the setup needs a running system, it is not a unit test.

graph LR
  A[Arrange<br/>build the unit + doubles] --> B[Act<br/>call one method]
  B --> C[Assert<br/>check the result or state]
  C -->|pass| D[Green<br/>milliseconds]
  C -->|fail| E[Red<br/>one failing assertion]
  style D fill:#E8F5E9
  style E fill:#FFEBEE

Three properties define a healthy unit test. Fast: a single test in the low milliseconds, the whole suite in seconds-to-low-minutes. Deterministic: no clock, no random, no network; the same input produces the same output every time. Isolated: no shared state between tests; running them in random order or in parallel produces the same result.