超时测试

超时测试

@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秒
	}
}

测试结果,超时的用例会执行失败
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_42884654/article/details/82911181