No More Flaky Clock Tests

Опубликовано: 19 Июнь 2026
на канале: James Shore
525
12

Every week in my Tuesday Lunch & Learn livestream, we choose a useful software development skill, define a challenge related to that skill, and solve the challenge live. This week, we’re preventing flaky clock tests.

There’s nothing more frustrating than flaky tests: tests that fail randomly. You end up having to run your test suite over and over to get a good result, even if there’s nothing wrong with your actual code. And code that involves time—that interacts with the system clock—are one of the most common cause of flaky tests.

In today’s episode, we kill flaky clock tests dead. If you use these techniques, you’ll never have another flaky clock test.

To follow along, download the code from Ghttps://github.com/jamesshore/livestr... and check out the 2020-07-14 tag. To see the final result, check out the 2020-07-14-end tag or view it on GitHub at https://github.com/jamesshore/livestr....