Test Isolation
Pronunciationtest eye-suh-LAY-shun
Definition
Test isolation means each test sets up its own state and cleans up after itself, so tests pass in any order and one failure cannot cause another.
Where you hear it
In flaky-test hunts, test-order bugs, and database test setups with transactions or fresh data.
Examples
The test passes alone but fails in the full suite, so isolation is broken.
Each test runs inside a transaction that is rolled back.
Each test rolls back its own changes, so the order in which the tests run does not matter.
Common mistake
Sharing a module-level list or database rows between tests. The order then decides who passes.
Don't confuse with
A test fixture, which is a tool for creating the clean state. Isolation is the goal the fixtures serve.
Say it at work
- In a meeting or chat
Randomise the order to check isolation.
- In an email or ticket
Reset the state in teardown.
Keep exploring
More in Testing & Quality