@Test public void testStartWhenStarted() { StopWatch stopWatch = createStopWatch(1); stopWatch.start(); try { stopWatch.start(); fail("Should not be able to start a started watch"); } catch (IllegalStateException e) { } }
public void start() { if (state != State.STOPPED) { throw new IllegalStateException("Cannot stop a Stopwatch that is already running"); } lastStartTime = timeProvider.nanoTime(); state = State.RUNNING; }
StopWatch { public void start() { if (state != State.STOPPED) { throw new IllegalStateException("Cannot stop a Stopwatch that is already running"); } lastStartTime = timeProvider.nanoTime(); state = State.RUNNING; } }
StopWatch { public void start() { if (state != State.STOPPED) { throw new IllegalStateException("Cannot stop a Stopwatch that is already running"); } lastStartTime = timeProvider.nanoTime(); state = State.RUNNING; } StopWatch(TimeProvider timeProvider); }
StopWatch { public void start() { if (state != State.STOPPED) { throw new IllegalStateException("Cannot stop a Stopwatch that is already running"); } lastStartTime = timeProvider.nanoTime(); state = State.RUNNING; } StopWatch(TimeProvider timeProvider); void start(); void stop(); long getElapsed(TimeUnit timeUnit); void combine(StopWatch that); }
StopWatch { public void start() { if (state != State.STOPPED) { throw new IllegalStateException("Cannot stop a Stopwatch that is already running"); } lastStartTime = timeProvider.nanoTime(); state = State.RUNNING; } StopWatch(TimeProvider timeProvider); void start(); void stop(); long getElapsed(TimeUnit timeUnit); void combine(StopWatch that);  }