Test pollution

Test pollution image
Test pollution happens when one test leaves behind data or a system state that affects another test. The failure appears unrelated, but the root cause is shared context leaking between tests.

This usually shows up when shared data is not cleaned up, system state is reused unintentionally, or resources remain locked or modified after a test finishes. As test suites grow, these hidden dependencies create failures that are hard to reproduce and even harder to trust.

For example, a user registration test creates abc@xyz.com but doesn’t delete it. Later, another test tries to register the same email and fails with “email already exists.” The second test looks broken, but the real issue is that the first test polluted the system. The failure depends on execution order, which makes it flaky and misleading.

The core problem is not the assertion, it’s isolation. Reliable tests must assume they run alone. That often means rolling back test transactions, generating unique test data, or running tests in disposable environments such as containers that are destroyed after each run.
One way teams uncover test pollution is by running tests in random order or executing individual tests in isolation. If results change based on order, hidden dependencies are already present.
Explore MoT
MoT Athens image
Fri, 5 Jun
MoT Athens Meetup #18: Summer meetup 2026
MoT Software Testing Essentials Certificate image
Boost your career in software testing with the MoT Software Testing Essentials Certificate. Learn essential skills, from basic testing techniques to advanced risk analysis, crafted by industry experts.
This Week in Quality image
Debrief the week in Quality via a community radio show hosted by Simon Tomes and members of the community
Subscribe to our newsletter