Faster StopWatchTest

- testFormatSplitTime()
- testFormatSplitTimeWithMessage()
This commit is contained in:
Gary Gregory 2024-09-04 11:35:56 -04:00
parent b657ed8389
commit b23c2d3836
1 changed files with 2 additions and 3 deletions

View File

@ -49,7 +49,6 @@ public class StopWatchTest extends AbstractLangTest {
private static final Duration TWO_MILLISECOND = Duration.ofMillis(2);
private static final Duration MILLIS_550 = Duration.ofMillis(550);
private static final String MESSAGE = "Baking cookies";
private static final Duration MIN_SLEEP = Duration.ofMillis(20);
private static final String ZERO_HOURS_PREFIX = "00:";
private static final String ZERO_TIME_ELAPSED = "00:00:00.000";
@ -163,7 +162,7 @@ public class StopWatchTest extends AbstractLangTest {
@Test
public void testFormatSplitTime() {
final StopWatch watch = StopWatch.createStarted();
ThreadUtils.sleepQuietly(MIN_SLEEP);
ThreadUtils.sleepQuietly(TWO_MILLISECOND);
watch.split();
final String formatSplitTime = watch.formatSplitTime();
assertNotEquals(ZERO_TIME_ELAPSED, formatSplitTime);
@ -174,7 +173,7 @@ public class StopWatchTest extends AbstractLangTest {
public void testFormatSplitTimeWithMessage() {
final StopWatch watch = new StopWatch(MESSAGE);
watch.start();
ThreadUtils.sleepQuietly(MIN_SLEEP);
ThreadUtils.sleepQuietly(TWO_MILLISECOND);
watch.split();
final String formatSplitTime = watch.formatSplitTime();
assertThat("formatSplitTime", formatSplitTime, not(startsWith(MESSAGE)));