【问题标题】:how to control the number of threads for execution in cucumber testNG parallel如何控制黄瓜testNG并行执行的线程数
【发布时间】:2022-07-29 07:56:24
【问题描述】:

我正在尝试使用 TestNG 和 SpringBootTest 并行和顺序运行 2 个 Cucumber 测试,但是当我的测试执行时会发生以下情况

mvn 测试

2 个浏览器打开并且都导航到 Wikipedia 主页。

如果您再添加 2 个场景,它会为每个场景打开那么多线程,我无法控制要执行的线程数。

如何控制线程数和dataprovider计数,不胜感激。

回购:https://github.com/cmccarthyIrl/spring-cucumber-testng-parallel-test-harness

【问题讨论】:

    标签: cucumber testng-dataprovider cucumber-spring


    【解决方案1】:

    可能的原因是,您使用的运行程序将其转换为 testng 数据驱动测试,其中包含通过数据提供程序提供的每个功能文件的场景的单个测试。这不是正确的做法。但是,在 testng 中有单独的属性来设置数据驱动测试的线程数。您可以在套件杠杆的xml配置文件中设置data-provider-thread-count,也可以通过命令行参数-dataproviderthreadcount指定线程数。


    更好的方法

    您可以使用本机 testng 实现查看另一个库 qaf-cucumber。它正在考虑每个场景,因为 testng 测试方法可以更好地控制和利用 testng 的每个功能。有了这个库,只有带有示例的场景才能转换为 testng 数据驱动测试。

    你不需要额外的类来运行测试。只需使用工厂可用类来拥有不同的configuration combinations。这是示例配置文件:

    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
    <suite name="QAF Demo" verbose="1">
        <test name="Web-Suite"  enabled="true">
            <classes>
                <class name="com.qmetry.qaf.automation.cucumber.runner.CucumberScenarioFactory" />
            </classes>
        </test>
    </suite>
    
    

    注意:截至今天,qaf-cucumber 支持 cucumber 5.x

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 2015-11-10
      • 1970-01-01
      • 1970-01-01
      • 2017-10-27
      • 1970-01-01
      相关资源
      最近更新 更多