Skip to content
Ameen Abozaid
Planned lessonJNR-047-L05

Demo: hunting a flaky test

  • Lesson 5 of 5
  • Junior
On This Lesson 3 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

find the cause of a flaky test and fix it. Prepares JNR-047-LAB1.

Draft outline details

Step by step

  1. Run the suite ten times and note which test fails sometimes.
  2. Run that test alone, then in random order, to see whether it depends on order.
  3. Spot the cause: it uses LocalDate.now() near midnight, or leftover data.
  4. Inject a fixed Clock and use unique data.
  5. Planned mistake: add Thread.sleep and see it still flake; replace with a deterministic clock.
  6. Run ten times again and record the runtime.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.