Skip to content

Commit

Permalink
Faster StopWatchTest.testStopInstantSimple()
Browse files Browse the repository at this point in the history
- Replace Matcher calls with sane assertTrue()
  • Loading branch information
garydgregory committed Sep 4, 2024
1 parent 695986b commit b4e4c40
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,14 @@ public void testStatic() {
public void testStopInstantSimple() throws InterruptedException {
final StopWatch watch = StopWatch.createStarted();
final long testStartMillis = System.currentTimeMillis();
sleep(MILLIS_550);
sleep(TWO_MILLISECOND);
watch.stop();
final long testEndMillis = System.currentTimeMillis();
final Instant stopTime = watch.getStopInstant();
assertEquals(stopTime, watch.getStopInstant());
assertThat("stopTime", stopTime,
allOf(greaterThanOrEqualTo(Instant.ofEpochMilli(testStartMillis)), lessThanOrEqualTo(Instant.ofEpochMilli(testEndMillis))));
// Only less than, not equal
assertTrue(testStartMillis < testEndMillis);
assertTrue(Instant.ofEpochMilli(testStartMillis).isBefore(Instant.ofEpochMilli(testEndMillis)));
}

@Test
Expand Down

0 comments on commit b4e4c40

Please sign in to comment.