用@Test(timeOut = XXX) 指定超时时间,单位是毫秒

package com.janson;

import org.testng.annotations.Test;

public class TimeOutTest {

    @Test(timeOut = 3000) //毫秒
    public void testSuccess() throws InterruptedException{
        Thread.sleep(2000);
    }

    @Test(timeOut = 2000)
    public void testFailed() throws InterruptedException{
        Thread.sleep(3000);
    }
}

上面的测试用例一条执行成功,一条执行失败

相关文章:

  • 2021-11-04
  • 2021-07-29
  • 2021-09-09
  • 2021-06-03
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-03-06
  • 2022-02-12
  • 2021-04-18
  • 2022-12-23
  • 2021-04-16
  • 2021-05-30
  • 2021-06-02
相关资源
相似解决方案