Faster StopWatchTest.testStopInstantSimple()

- Replace Matcher calls with sane assertTrue()
This commit is contained in:
Gary Gregory 2024-09-04 11:32:53 -04:00
parent 695986b2b9
commit b4e4c40af1
1 changed files with 4 additions and 3 deletions

View File

@ -351,13 +351,14 @@ public class StopWatchTest extends AbstractLangTest {
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