TestNG Tutorial 4 – Time Test
Written on
May 12, 2009 at 1:59 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.testng.annotations.*;
/**
* TestNG TimeOut Test
* @author mkyong
*
*/
public class TestNGTest4 {
@Test(timeOut = 1000)
public void infinity() {
while (true);
}
}Result
FAILED: infinity
org.testng.internal.thread.ThreadTimeoutException: Method public void TestNGTest4.infinity() didn’t finish within the time-out 1000
… Removed 18 stack frames


