/** * Tests the functionality for getEndTime */ public void testGetEndTime() { StopWatch watch = new StopWatch(); long endTime; try { Thread.sleep(10); } catch (InterruptedException e) { } // check if stop time is different from start watch.stop(); endTime = watch.getEndTime(); assertTrue(0 != endTime); // check if end time now is the same (we haven't started the timer agaiin assertEquals(endTime, watch.getEndTime()); }
/** * Tests the functionality of getTimeDiff */ public void testGetTimeDiff() { StopWatch watch = new StopWatch(); long startTime; long endTime; startTime = watch.getStartTime(); watch.stop(); endTime = watch.getEndTime(); assertEquals(endTime - startTime, watch.getTimeDiff()); }