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