A flaky test gives different results for the same code. Common causes in API testing are timing — asserting before an asynchronous job finishes — shared state between tests, data left over from earlier runs, real network calls, unseeded random data, and dependence on the current date or time zone.
Flakiness is diagnosed by rerunning the same commit until the failure reproduces and comparing what differed. It is fixed by removing the source of variation: wait for a condition instead of a fixed time, give each test its own data, seed generators, freeze clocks, and replace live dependencies with a fake or a sandbox you control.
That an automatic retry fixes a flaky test. Retries hide the symptom and keep the cause; they also hide real intermittent bugs in the product — a race condition looks exactly like a flaky test. Quarantine and fix, rather than retry and forget.
POST /protocol/v1/jobs returns 202 and the job progresses on each poll of GET /protocol/v1/jobs/{id} — a good place to practise waiting for a condition instead of sleeping. Reset the sandbox between runs to keep state from leaking.
All glossary terms · Testing techniques · All 39 mock REST APIs
Last updated