Quality

Flaky tests: finding and fixing them

A test that sometimes fails teaches the team to ignore failures. How to find flaky tests, fix the usual causes and keep new ones out.

GloryTekSystems team2 Jan 2026 2 min read

A whiteboard with to-do, in-progress and done columns

A flaky test passes and fails on the same code. Each one seems harmless, but together they teach developers to re-run the pipeline and ignore red builds, and that is exactly when a real failure slips through.

Find them

Track test results over time and flag tests that fail and then pass on a retry without any code change. Most CI tools and test reporters can do this. Rank them by how often they fail and how many builds they block.

Common causes

  • Fixed waits instead of waiting for a condition, such as an element appearing
  • Tests that depend on each other’s data or on run order
  • Shared environments where other tests change the data
  • Time zones, dates and clocks, especially around midnight and month ends
  • Unreliable external services called directly from tests

Fix the cause, not the symptom

Replace sleeps with explicit waits for the expected state. Give each test its own data and clean up afterwards. Use fixed clocks in tests that depend on time. Replace external services with stable fakes or sandboxes in most tests, and keep a few contract tests against the real thing.

A clear policy

Quarantine a flaky test straight away so it stops blocking others, give it an owner and fix or delete it within a set time. A test nobody fixes is not protecting anything.

Written by the GloryTekSystems team

Our engineers and consultants write about what they see in real projects. Have a question about your own systems?

Ask us
GloryTek assistantQuick answers · automated

Hi, I’m the GloryTek assistant. Ask me about our services, pricing, timelines or industries.

Popular pages

↑↓ to move to open Esc to close