Skip to content

Commit

Permalink
Faster StopWatchTest
Browse files Browse the repository at this point in the history
- testFormatSplitTime()
- testFormatSplitTimeWithMessage()
  • Loading branch information
garydgregory committed Sep 4, 2024
1 parent b657ed8 commit b23c2d3
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -163,7 +162,7 @@ public void testBooleanStates() {
@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);
Expand All @@ -174,7 +173,7 @@ public void testFormatSplitTime() {
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)));
Expand Down

0 comments on commit b23c2d3

Please sign in to comment.