# Arrange-Act-Assert (AAA)

> A test in three steps. Set it up, run it, then check the result.

**Field:** Software Development  
**Category:** Testing & Quality  
**Also known as:** AAA Pattern, Arrange Act Assert, AAA Test Pattern

## Think of it like

Think of it like a magic trick. You set up the cards, you do the trick, and then you show the card.

## Definition

Arrange-Act-Assert is a simple shape for writing one test. First you arrange: you set up the inputs. Then you act: you run the one thing being tested. Then you assert: you check the result is what you expect. Keeping the three parts apart makes a test easy to read.

## Example

Jack's test sets a price of 100, runs addTax and checks the answer is 120. Each step is one line.

## Example code

```javascript
test("adds tax to the price", () => {
  const price = 100;            // Arrange
  const total = addTax(price);  // Act
  expect(total).toBe(120);      // Assert
});
```

Three lines, three steps: set up, run, check.

## Why it matters

Anyone can read a test shaped this way and see what it proves.

## Common mistake

Acting and asserting many times in one test. When it fails, you cannot tell which part broke.

## Three principles

- **Arrange.** Set up the inputs.
- **Act.** Run one thing.
- **Assert.** Check the result.

## Related terms

- [Test Case](https://learn.benibix.com/term/development/test-case)
- [Assertion](https://learn.benibix.com/term/development/assertion)
- [Test Fixture](https://learn.benibix.com/term/development/test-fixture)
- [Unit Test](https://learn.benibix.com/term/development/unit-test)
- [Behavior-Driven Development (BDD)](https://learn.benibix.com/term/development/behavior-driven-development)

![One test drawn as a row of steps. First a fixture box sets up a cart holding a mug. Then three lit-up steps: arrange, set up the inputs; act, run the one thing being tested; assert, check the result. Last, teardown cleans up. Below, two paths branch from the same feature: the happy path, where a valid card pays, and edge cases, like an empty cart or an expired card.](https://learn.benibix.com/diagrams/dev3-test-anatomy.svg)

---

Source: https://learn.benibix.com/term/development/arrange-act-assert
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
