zoukankan      html  css  js  c++  java
  • testNG超时测试

    超时测试是指如果测试未超时则通过,反之则自动停止并置为运行失败;

    testNG超时设置的时间是通过 测试脚本方法上添加@Test()timeOut参数控制的,如果@Test(timeOut = 3000),3000为毫秒数,1000毫秒=1秒。

    java代码如下

     1 package com.course.testng;
     2 
     3 import org.testng.annotations.Test;
     4 
     5 public class TimeOutTest {
     6     @Test(timeOut = 3000)//单位是毫秒值  1000等于1秒
     7     public void testSuccess() throws InterruptedException {
     8         Thread.sleep(2000);
     9     }
    10 
    11     @Test(timeOut = 3000)
    12     public void testFailed() throws InterruptedException {
    13         Thread.sleep(4000);
    14     }
    15 }

    运行结果如下

      C:UsersAdministrator.IntelliJIdea2019.3system	emp-testng-customsuite.xml
    
    
    
    org.testng.internal.thread.ThreadTimeoutException: Method com.course.testng.TimeOutTest.testFailed() didn't finish within the time-out 3000
    
        at java.util.concurrent.ThreadPoolExecutor.tryTerminate(ThreadPoolExecutor.java:706)
        at java.util.concurrent.ThreadPoolExecutor.processWorkerExit(ThreadPoolExecutor.java:1007)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
    
    
    ===============================================
    Default Suite
    Total tests run: 2, Failures: 1, Skips: 0
    ===============================================
    
    
    Process finished with exit code 0
  • 相关阅读:
    DSP28335 烧写到RAM和FLASH方法
    脉冲提取
    基于飞秒光频梳的正弦相位调制干涉绝对距离测量方法研究 -张世华
    DSP28335 IO口寄存器
    DSP28335 使用技巧
    freertos、UCos这种实时操作系统和Linux、Windows这种系统的 本质区别
    stm32的定时器输入捕获 与输出比较
    五大常用算法--回溯
    Dijkstra算法
    字典树-Trie
  • 原文地址:https://www.cnblogs.com/linxinmeng/p/12593711.html
Copyright © 2011-2022 走看看