什么是超时测试
当测试用例超过timeOut设定的时间,则认为用例执行失败,继续运行下面的用例。
如何使用
@Test(timeout=“毫秒值”)
举例
import org.testng.annotations.Test;
public class TimeOut {
@Test(timeOut = 3000)
public void test1() throws InterruptedException {
Thread.sleep(2000);
}
@Test(timeOut = 3000)
public void test2() throws InterruptedException {
Thread.sleep(3500);
}
}
执行TimeOut类,结果如下
test2执行超过设定的超时时间,执行失败。