Skip to content

Tests go beyond correctness. They're about confidence.

MAIN refactor: swap the booking backend pytest fails here 4 minutes after the cause, not 4 weeks, in production reproducible the same failure, on demand regression-proof yesterday's bug cannot come back documentation the only spec that cannot go stale licence to change the reason the other three matter at all
svg - tests' main purposes

Why tests?

Ask why people write tests and you get a few different answers. Tests make a failure reproducible, so you can look at it whenever you like instead of waiting for it to happen again. They make bugs non-recurring: the fix comes with a guard, so yesterday's incident cannot be reintroduced next quarter by someone who never heard about it. They are documentation that cannot drift, because a lie in a test suite fails loudly.

The fourth is the one that actually pays for the other three: a test suite is what lets you change code you no longer remember writing. Rename the function, swap the backend, upgrade the dependency, and the suite tells you within minutes whether you got away with it.

Tests are not always perfect: edge cases, exceptions, and much more can cause tests to pass with bad behavior. But more than ensuring correctness, tests raise when unexpected changes occur. In the age of Agentic AI, that matters most because "my agent works" is not the interesting question. "My agent still works, after I edited the prompt" is.

But before going any further, what exactly is a test? How do we write them in Python?

Go deeper