TestNg 11. 超时测试

前沿:多久时间没有响应,就是超时。

代码:用timeOut这个属性,超过规定的时间就是fail,不超过就是success

package com.course.testng;

import org.testng.annotations.Test;

public class TimeOutTest {

    @Test(timeOut = 3000) //单位为毫秒值
    public void timeSuccess() throws InterruptedException{
        Thread.sleep(2000);
    }

    @Test(timeOut = 2000) //单位为毫秒值
    public void timeFail() throws InterruptedException{
        Thread.sleep(3000);
    }
}

结果:

原文地址:https://www.cnblogs.com/peiminer/p/9591177.html