QamoosTech
Testing & QualityTest designBeginnerPython

Arrange, Act, Assert

Pronunciationuh-RAYNJ AKT uh-SERT

Definition

Arrange, Act, Assert is a pattern for clear tests: set up the data (arrange), run the one thing under test (act), then check the result (assert).

Where you hear it

In testing guides, code reviews of tests, and BDD-style "given, when, then" discussions.

Examples

  • Keep the test in three blocks: arrange, act, assert.
  • This test acts twice, so it is hard to tell what failed.
  • Arrange a cart with two items, act by calling checkout, then assert the total is 40.

Common mistake

Mixing steps, with asserts in the middle and several actions. When it fails you can't tell which step is to blame.

Don't confuse with

A test fixture, which shares the arrange step across many tests. The pattern describes one test's shape.

Say it at work

  • In a meeting or chatSplit it so each test has one act.
  • In an email or ticketName the test after what the act does.