1 package test.timeout; 2 3 import org.testng.annotations.Test; 4 5 /** 6 * This class tests timeouts 7 * 8 * @author cbeust 9 */ 10 public class TimeOutSampleTest { 11 12 @Test(timeOut = 5_000 /* 5 seconds */) timeoutShouldPass()13 public void timeoutShouldPass() { 14 } 15 16 @Test(timeOut = 5_000 /* 5 seconds */) timeoutShouldFailByException()17 public void timeoutShouldFailByException() { 18 throw new RuntimeException("EXCEPTION SHOULD MAKE THIS METHOD FAIL"); 19 } 20 21 @Test(timeOut = 1_000 /* 1 second */) timeoutShouldFailByTimeOut()22 public void timeoutShouldFailByTimeOut() throws InterruptedException { 23 Thread.sleep(10_000 /* 10 seconds */); 24 } 25 } 26