State leakage

State leakage image
State leakage happens when data, configuration, or system state from one action, test, or user session unintentionally affects another. Instead of starting from a clean and predictable state, behaviour is influenced by something left behind earlier.

This often shows up in tests that pass when run alone but fail when run together. For example, a test might rely on data created by a previous test, a user session might remain active longer than expected, or a cached value might change the outcome of a later action. The system appears inconsistent, even though the logic itself has not changed.

State leakage is risky because it hides real problems. Tests may pass for the wrong reasons, failures may be hard to reproduce, and bugs may only appear in certain orders or environments. This can lead to flaky tests and false confidence in system stability.

Reducing state leakage involves being clear about setup and cleanup, isolating tests where possible, and validating assumptions about system state. When state is controlled and predictable, behaviour becomes easier to reason about and failures become easier to trust.
Explore MoT
RiskStorming: Artificial Intelligence image
RiskStorming; Artificial Intelligence is a strategy tool that helps your team to not only identify high value risks, but also set up a plan on how to deal
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.
Into The Motaverse image
Into the MoTaverse is a podcast by Ministry of Testing, hosted by Rosie Sherry, exploring the people, insights, and systems shaping quality in modern software teams.
Subscribe to our newsletter
We'll keep you up to date on all the testing trends.