测试方法是否超时
import org.testng.annotations.Test;
public class TimeOutTest {
//等待时间,单位为毫秒
@Test(timeOut=3000)
public void testSuccess() throws InterruptedException{
Thread.sleep(2000);
}
}
运行结果

本文介绍了一个简单的测试案例,展示了如何使用 TestNG 框架中的 @Test 注解来设置测试方法的时间限制,以实现对测试执行超时的控制。
测试方法是否超时
import org.testng.annotations.Test;
public class TimeOutTest {
//等待时间,单位为毫秒
@Test(timeOut=3000)
public void testSuccess() throws InterruptedException{
Thread.sleep(2000);
}
}
运行结果

882
1288

被折叠的 条评论
为什么被折叠?