Clock { public String update() { long elapsedTime = System.currentTimeMillis() - startTime; long seconds = elapsedTime / 1000; long milliSecs = elapsedTime % 1000; String prefix; if ( milliSecs < 10 ) { prefix = "00"; } else if ( milliSecs < 100 ) { prefix = "0"; } else { prefix = ""; } return seconds + ""; } Clock(); String update(); void reset();  }
@Test public void testUpdate() { String str1 = instance.update(); try { Thread.sleep( 1000 ); } catch ( InterruptedException ex ) { Logger.getLogger( ClockTest.class.getName() ).log( Level.SEVERE, null, ex ); } String str2 = instance.update(); if ( str1.equals( "0" ) && !str2.equals( "0" ) ) { assertTrue( true ); } else { assertTrue( false ); } }