# New tests must fail first, for the right reason

> Today I Learned: New tests must fail first, for the right reason

Canonical: https://short.inc/today-i-learned/tests-must-fail-for-the-right-reason

Date: 05 nov 26
Author: Zeno Popovici

Ask an agent for a feature with tests and it often writes both at the same time. The tests pass on the first run, everything is green, and you feel great.

You shouldn't. A test that has never failed hasn't proved anything yet.

```text
Write the tests first. Run them.
Each new test must fail, and fail for the right reason:
the behaviour is missing, not a typo or a bad import.
Show me the failure output. Then write the code.
```

There's a second rule, for the opposite direction:

```text
Never change what an existing test asserts to make code pass.
An assertion you think is wrong goes to me.
```

You need that second one. The fastest way to a green build is to edit the test, and an agent that wants to finish will find it. To be fair, so will a developer on a Friday afternoon.
