# `test.assertion_failed`

A test's `assert` doesn't hold: its condition is false, or a call checked with `assert … fails` returned or failed differently.

Area 13, [Testing](/docs/testing.md); not declinable; the next step is usually the agent's.

## Why Jadpo refuses it

An `assert` is the test saying what the code should do. When it doesn't
hold, the test and the code disagree, and only one of them is right.
The report shows each side of the comparison, records field by field
with a diff of what differs, so you can tell which without running the
test again.

## What it looks like

todos.test.jadpo, testing `draft` in todos.jadpo, which makes a todo with
priority 3:


```jadpo
test "a new draft has normal priority" {
    var fresh: TodoDraft = draft("Buy milk")
    assert fresh == TodoDraft {
        title: "Buy milk"
        priority: 2
    }
}
```

```text
FAIL  a new draft has normal priority
 --> todos.test.jadpo:3

  assert fresh == TodoDraft { ...
         |        |
         |        TodoDraft { title: "Buy milk", priority: 2 }
         TodoDraft { title: "Buy milk", priority: 3 }

  expected: TodoDraft { title: "Buy milk", priority: 2 }
  actual: TodoDraft { title: "Buy milk", priority: 3 }
  diff: ~ priority: expected 2, actual 3

  rule: test.assertion_failed
  rerun: jadpo test todos.test.jadpo:3 --seed 1

test failed: 1 failed, 1 pure test
```

A failed test's report has no `next:` line, and the rule is your agent's
to act on. `(agent)` at the end of the `next:` line means your coding
agent can make the fix itself. The `rerun:` line runs this one test
again with the same seed.

## How to fix it

The question is which is right, the test or the code.

**If the code is right**, change what the test expects. In
`todos.test.jadpo`:

```jadpo
        priority: 3
```



The test now expects the priority `draft` gives, and passes.

**If the test is right**, change the code. In `todos.jadpo`:

```jadpo
        priority: 2
```



Every new draft now has priority 2, and the test passes.

## Related

- [Assertions](/docs/assertions.md)
- [Comparing values](/docs/assertions.md#comparing-values)
- [What a failed test reports](/docs/assertions.md#what-a-failed-test-reports)
- [Checking that a call fails](/docs/assertions.md#checking-that-a-call-fails)
