超时测试
@Test(timeOut = 3000) //超时测试,单位为毫秒值
在com.course.testng包中新建TimeOutTest类,代码如下:
package com.course.testng;
import org.testng.annotations.Test;
public class TimeOutTest {
@Test(timeOut = 3000) //超时测试,单位为毫秒值
public void testSuccess() throws InterruptedException{
Thread.sleep(2000); //睡眠2秒
}
@Test(timeOut = 2000) //超时测试,单位为毫秒值
public void testFail() throws InterruptedException{
Thread.sleep(3000); //睡眠3秒
}
}
测试结果,超时的用例会执行失败