Promptles
Testing & Quality

Flaky Test

intermediate

Definition

A test that sometimes passes and sometimes fails for no clear reason: usually because it depends on something it shouldn't, like the time of day, the order other tests ran in, or how fast the network is responding. Flaky tests slowly destroy the team's trust in the whole test suite.

In the wild

A test for a 'session expires after one second' feature passes most of the time, but every Tuesday morning it fails when the laptop is busy and the test pauses for slightly more than a second. The test isn't wrong about the rule: it's just relying on the real clock, which is unreliable. The fix is to use a fake clock the test can control.

More from Testing & Quality