Junit 4 Tutorial 4 – Time Test
Written on
May 20, 2009 at 2:41 pm by
mkyong
The “Time Test” means if an unit test takes longer than the specified number of milliseconds to run, the test will terminated and mark as fails.
import org.junit.*;
/**
* JUnit TimeOut Test
* @author mkyong
*
*/
public class JunitTest4 {
@Test(timeout = 1000)
public void infinity() {
while (true);
}
}Result
java.lang.Exception: test timed out after 1000 milliseconds


