# Flaky Test

> A test that passes on one run and fails the next, with no code change.

**Field:** Software Development  
**Category:** Testing & Quality  
**Also known as:** Flaky Tests, Flakiness, Intermittent Test

## Think of it like

Think of it like a smoke alarm that goes off at random. Soon nobody trusts it.

## Definition

A flaky test passes sometimes and fails other times, with no change to the code. Common causes are timing, tests that depend on each other's order, and calls to the real network. A test that waits a fixed half second for a page can fail when the machine is busy. Flaky tests teach people to ignore red results. That is how a real failure slips through.

## Example

Lucy's checkout test fails about one run in ten. It waits 500 milliseconds for the page, and on a busy build server that is not enough.

## Why it matters

One flaky test makes the whole suite less trusted. People start pressing rerun instead of reading the failure.

## Common mistake

Fixing a flaky test by adding a longer sleep. Wait for the thing you need, like the button showing up.

## Three principles

- **Same code, different result.** Pass, then fail.
- **Timing, order, network.** The usual causes.
- **Fix it fast.** Or nobody trusts red.

## Related terms

- [End-to-End Test (E2E)](https://learn.benibix.com/term/development/end-to-end-test)
- [Test Suite](https://learn.benibix.com/term/development/test-suite)
- [Asynchronous Code](https://learn.benibix.com/term/development/asynchronous-code)
- [Software Testing](https://learn.benibix.com/term/development/software-testing)

---

Source: https://learn.benibix.com/term/development/flaky-test
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
