mockito/mockito — pull request #15 by pimterry (2013-07-31 14:20:15+00:00)
Title: Fix timeout sleep handling to track time more accurately, and tidy timeout impl variable names

The previous timeout implementation doesn't measure time correctly: it only counts time spent intentionally sleeping, thus losing time on anything that happens when not sleeping (both the actual verification time, and time spent in other threads during verification), and gaining time if any InterruptedExceptions occur.

Typically this means that timeout()s actually run for a longer than they're intended to. The fixed test demonstrates this well; previous the timeout was set to exactly the minimum possible time the sleeps in the code alone could've taken, ignoring all processing time, and this test consistently passed. After the changes it now fails (as it probably should).

This patch fixes that by just measuring the time directly. I've also fixed some variables names that were slightly annoying, and that now-failing test has a 500ms buffer before it times out.