### Question:
ProgressiveSleepWaitStrategy implements WaitStrategy { @Override public void snooze() { if (invocations < yieldCount) { yield(); invocations++; } else { int millis = invocations - yieldCount + initialSleepMillis; sleep(millis); if (millis < maxSleepMillis) { invocations++; } } } ProgressiveSleepWaitStrategy();  ProgressiveSleepWaitStrategy(int yieldCount, int initialSleepMillis, int maxSleepMillis); @Override void reset(); @Override void snooze();  }### Answer:
@Test public void at_first_yields() { waitStrategy = new SpiedProgressiveSleepWaitStrategy(3, 1, 10); for (int i = 0; i < 3; i++) { waitStrategy.snooze(); } assertThat(spy, is(asList("yield", "yield", "yield"))); }
@Test public void sleeps_progressively_longer_times() { waitStrategy = new SpiedProgressiveSleepWaitStrategy(0, 1, 10); for (int i = 0; i < 3; i++) { waitStrategy.snooze(); } assertThat(spy, is(asList("sleep 1", "sleep 2", "sleep 3"))); }
@Test public void the_initial_sleep_time_is_configurable() { waitStrategy = new SpiedProgressiveSleepWaitStrategy(0, 5, 10); for (int i = 0; i < 3; i++) { waitStrategy.snooze(); } assertThat(spy, is(asList("sleep 5", "sleep 6", "sleep 7"))); }
@Test public void sleeps_at_most_the_maximum_sleep_time() { waitStrategy = new SpiedProgressiveSleepWaitStrategy(0, 1, 10); for (int i = 0; i < 9; i++) { waitStrategy.snooze(); } spy.clear(); for (int i = 0; i < 3; i++) { waitStrategy.snooze(); } assertThat(spy, is(asList("sleep 10", "sleep 10", "sleep 10"))); }