Skip to content

The four-phase test

Every well-formed unit test has four phases: setup, exercise, verify and teardown; the fixture covers the first and the fourth.

  1. Phase 1 — Fixture setup: create the objects, rows or files the test needs.

  2. Phase 2 — Exercise SUT: call the one method or function under test.

  3. Phase 3 — Result verification: assert on the returned value or the state left behind.

  4. Phase 4 — Fixture teardown: release resources, drop the database, delete the files.