Constrained test order occurs when one test depends on another test having run—or not run—because both rely on shared state. A test runner may change the order, exposing failures that are difficult to diagnose. section 8.1.3
A shared cache creates the dependency
One test adds user "a" to a shared UserCache; a later test expects login for that user to succeed. The first test fails if the cache already contains the user, while the third fails if the second has not run. Running only the third test also reveals the hidden setup dependency.
Remove order dependence by making each test establish its own state:
- Treat tests as independently runnable rather than relying on runner order. section 8.1.3
