• 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
     
     

     

  • 相关阅读:
    MongoDB 基础API使用
    MongoDB -- JAVA基本API操作
    Docker数据管理
    Docker容器的简单使用
    Docker
    Centos 7.3 镜像制作
    Fuel部署OpenStack
    Fuel
    Ceph添加、删除osd及故障硬盘更换
    ceph常用命令
  • 原文地址:https://www.cnblogs.com/longronglang/p/6123778.html
Copyright © 2020-2023  润新知