---
title: "Give each test one reason to fail · Agent Wranglers"
url: https://agentwranglers.se/playbook/testing/unit-tests/one-reason-to-fail
updated: 2026-10-20
licence: "All rights reserved"
---

# Give each test one reason to fail

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Recommended
- Chapter: [Unit tests](https://agentwranglers.se/playbook/testing/unit-tests)
- Rule: Each test checks one behaviour. When it fails, its name tells you what broke.
- How: Split a test that checks unrelated things into several tests. Several assertions are fine when they describe one result, such as the fields of one returned object. Name tests as plain sentences, such as "rejects an expired coupon".
- Check: Break one behaviour on purpose. Exactly one test, or a small group about that behaviour, fails.

Example:

```php
// Bad: two behaviours in one test
public function testCoupons(): void { /* expired and wrong-currency cases */ }

// Good: one behaviour each
public function testRejectsAnExpiredCoupon(): void { /* ... */ }
public function testRejectsACouponInAnotherCurrency(): void { /* ... */ }
```

```python
# Good: one behaviour each
def test_rejects_an_expired_coupon(): ...

def test_rejects_a_coupon_in_another_currency(): ...
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers testing playbook: https://agentwranglers.se/playbook/testing/unit-tests/one-reason-to-fail`.

- Previous: [Arrange, act and assert](https://agentwranglers.se/playbook/testing/unit-tests/arrange-act-assert)
- Next: [Keep unit tests fast](https://agentwranglers.se/playbook/testing/unit-tests/fast-unit-tests)
- [Unit tests](https://agentwranglers.se/playbook/testing/unit-tests)
