Selenium / Scenario

The Sleep(5000) Intervention

A junior's PR makes the suite pass by sprinkling Thread.sleep(5000) in eleven places. It also makes the suite 9 minutes slower and still flaky. Time for a review.

Difficulty
Easy
Format
Scenario
Points
100
Estimate
12 min

// MISSION BRIEF

Your Mission

You are reviewing a pull request titled 'fix flaky login tests'. The diff replaces failures with sleeps. It technically passes today. Your job: reject it for the right reasons and prescribe the right fix.

Read the diff and the CI timings, then make the calls. Decisions are weighted; wrong reasoning costs more than slow reasoning.

// FIRST CONTACT

Battle teaser

First artifact

The PR diff (excerpt)

Why is Thread.sleep(5000) the wrong tool even when it 'works'?

  1. Asleep() is deprecated in modern Java
  2. BIt works fine; the only issue is code style
  3. CIt always burns the full 5 seconds even when the app is ready in 200ms, and still fails whenever the app takes 5.1s, worst of both worlds
Answers, scoring, hints, and the full battle stay sealed.

// SKILL TAGS

seleniumwaitsflakinesscode-reviewjava