New: Practical guidance for AI-assisted quality engineering
AskAQA / Quality Engineering / Why Automated Tests Become Flaky
Quality Engineering · Cornerstone Guide 08

Why Automated Tests Become Flaky

Understand the most common causes of flaky automated tests and how to eliminate unreliable timing, state, data, environment, selector, and dependency behaviour.

11 min readFor QA engineers, SDETs, developers, automation specialists, architects, and technical quality leaders.

What is a flaky test?

A flaky test produces inconsistent outcomes without a relevant product change. It passes, fails, then passes again under apparently equivalent conditions.

Rerun-until-green is not a reliability strategy. It hides signal quality problems.

Common causes

CauseExample
TimingTest acts before async work completes.
Shared stateTests modify the same account.
SelectorsLocator depends on changing DOM structure.
Data collisionParallel tests reuse identifiers.
EnvironmentService is intermittently unavailable.
Order dependencyTest passes only after another test.

Replace sleeps with conditions

Fragile
Wait 5 seconds and hope.
Reliable
Wait for the specific observable state required by the next action.

Classify failures

Automation Failure ├── Product defect ├── Test defect ├── Test data issue ├── Environment issue ├── Dependency issue └── Expected product change

Treat flakiness as technical debt

Track flake rate, assign ownership, repair high-value flaky tests quickly, and quarantine only temporarily.

If a test needs repeated retries to be trusted, the product, environment, data setup, or test code needs engineering attention.

Turn quality concepts into engineering practice

Connect automation, APIs, performance, data, environments, AI, governance, and release decisions.

Ask a QA Question

AskAQA AI assistant

Ask a QA

Ask me about automation, API testing, test architecture, coverage, CI/CD quality gates, performance, integration testing, or other quality engineering topics.

Do not include passwords, confidential information, or personal data in your question.