On Flaky Tests, Time Precision, and Order Dependence
A flaky test is one that fails unpredictably, without a corresponding change in the code under test. These often show up in CI runs where a test unrelated to any change made suddenly fails, and then mysteriously passes when re-run. There are many type and causes of “flakes”. Today I want to talk about flaky tests caused by time precision, and time-order dependence.
The specific tools mentioned here will be Ruby, Rails, and PostgreSQL specific. But analogs exist in nearly all other languages and frameworks, so the techniques are broadly applicable.
![Not sure if I broke something, or it's a flaky test… Frye meme: Not sure if I broke something, or it's a flaky test](/assets/images/posts/not-sure-if-flaky-test.jpg)