我在 src/test/resources/feature/ 中有以下功能文件(单独的功能文件),我想并行运行它们。比如:一个功能文件必须在 chrome 中执行,另一个功能文件必须在 firefox 中执行,如@Tags 名称所述。
Feature: Refund item
@chrome
Scenario: Jeff returns a faulty microwave
Given Jeff has bought a microwave for $100
And he has a receipt
When he returns the microwave
Then Jeff should be refunded $100
Feature: Refund Money
@firefox
Scenario: Jeff returns the money
Given Jeff has bought a microwave for $100
And he has a receipt
When he returns the microwave
Then Jeff should be refunded $100
有人可以帮助我实现这一点。我正在使用 cucumber-java 1.2.2 版本,并将 AbstractTestNGCucumberTests 用作跑步者。另外,让我知道如何使用功能文件动态创建测试运行程序并使它们并行运行。
原文由 ArrchanaMohan 发布,翻译遵循 CC BY-SA 4.0 许可协议
更新: 4.0.0 版本可在 maven 中央存储库中获得,其中包含大量更改。 有关更多详细信息,请访问此处。
更新: 2.2.0 版本可在 Maven 中央存储库中获得。
您可以使用开源插件 cucumber-jvm-parallel-plugin ,它比现有解决方案有很多优势。可在 maven 存储库 中获得
以上两个插件将为并行运行的黄瓜测试带来魔力(前提是您的机器还具有高级硬件支持)。
严格提供
<forkCount>n</forkCount>
这里的“n”与 1) 高级硬件支持和 2) 可用节点(即向 HUB 注册的浏览器实例)成正比。一项主要且最重要的更改是您的 WebDriver 类必须是 SHARED 并且您 不 应该实现 driver.quit() 方法,因为关闭是由 shutdown hook 负责的。
Really large (>50 node) Hub installations may need to increase the jetty threads by setting -DPOOL_MAX=512 (or larger) on the java command line.
java -jar selenium-server-standalone-<version>.jar -role hub -DPOOL_MAX=512