zoukankan      html  css  js  c++  java
  • TestNg线程池配置、执行次数配置、超时配置

    使用注解的方式对TestNg线程池配置、执行次数配置、超时配置

    注:使用注解来控制测试方法运行的次数和超时时间,timeOut在单线程或者多线程模式下都可用,threadPoolSize设置了线程池的个数 * ,在观察结果时,发现很多值是重复的,但是可能不等于我们配置的线程池个数,因为线程的个数还取决于硬件CPU的支持,

    invocationCount----表示执行的次数

    threadPoolSize-----表示线程池的内线程的个数

    timeOut-------超时时间-毫秒

    代码实例:

    public class TestngInvocationCount {  
        private static int sum = 0;  
      
        @Test(threadPoolSize = 2, invocationCount = 10, timeOut = 1000)  
        public void testServer() throws InterruptedException {  
            // 检测启动的线程数,当启动的个数超过CPU核数时,其实是重新在调度  
            // Thread.sleep(2000);  
            sum++;  
            System.out.println("........." + sum);  
        }  
      
    }  

    测试结果:

    [TestNG] Running:
      C:UsersAdministrator.IntelliJIdea2018.2system	emp-testng-customsuite.xml
    .........1
    .........2
    .........3
    .........4
    .........5
    .........6
    .........7
    .........8
    .........9
    .........10
    
    ===============================================
    Default Suite
    Total tests run: 10, Failures: 0, Skips: 0
    ===============================================
    
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    
    Process finished with exit code 0
     
     

     

  • 相关阅读:
    版本控制:SVN中Branch/tag的使用 -摘自网络
    安卓手机修改hosts攻略-摘自网络
    Web Api 2 怎么支持 Session
    几种判断asp.net中session过期方法的比较
    MSDN在线
    JS监听关闭浏览器事件
    VS调试Ajax
    SQL Server LEFT Functions
    Sql Server REPLACE函数的使用;SQL中 patindex函数的用法
    EXCEL公式测试使用Substitute
  • 原文地址:https://www.cnblogs.com/longronglang/p/6123778.html
Copyright © 2011-2022 走看看