---
title: "Keep unit tests fast · Agent Wranglers"
url: https://agentwranglers.se/playbook/testing/unit-tests/fast-unit-tests
updated: 2026-10-20
licence: "All rights reserved"
---

# Keep unit tests fast

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

- Level: Recommended
- Chapter: [Unit tests](https://agentwranglers.se/playbook/testing/unit-tests)
- Rule: Each unit test runs in milliseconds, and the whole unit suite runs in seconds.
- How: Keep unit tests free of disks, databases, networks and sleeps. Watch the slowest tests with the runner's report, such as `pytest --durations=10` or Vitest's `slowTestThreshold` option. Move a slow test to the integration suite, or remove what makes it slow.
- Check: The slowest unit test takes under 100 milliseconds. The unit suite runs in under 30 seconds.

Example:

```sh
pytest tests/unit --durations=10
```

**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/fast-unit-tests`.

- Previous: [Give each test one reason to fail](https://agentwranglers.se/playbook/testing/unit-tests/one-reason-to-fail)
- [Unit tests](https://agentwranglers.se/playbook/testing/unit-tests)
