one reason to fail

The guideline that a single test should only be able to fail for one cause, even if it contains several assertions.

In more detail

People often quote the rule as one assertion per test, but the version that matters is one reason to fail. Several assertions about one returned value belong together, because they describe one behaviour. Assertions about unrelated behaviours belong in separate tests, because the first failure would hide the others.

Related terms

Taught in

References