gpt4 book ai didi

java - cucumber :循环场景中的步骤

转载 作者:行者123 更新时间:2023-11-28 21:36:31 28 4
gpt4 key购买 nike

我正在使用 Java、Intellij、Selenium + Cucubmer 编写测试。我有一个简单的测试场景:

  Scenario: Add X random products to the shopping cart

Given I choose a random product from a list
When I add random quantity of the product to the shopping cart
Then I see that number of products in the cart was updated

在最后一步之后,我应该转到第一步并重复所有过程 X 次。我不知道如何在不复制步骤的情况下在一种情况下实现它。是否可以循环运行步骤 1-3?

最佳答案

您可以将其转换为如下所示的虚拟ScenarioOutline,并将示例表扩展到您想要的任何时间。

  ScenarioOutline: Add X random products to the shopping cart

Given I choose a random product from a list
When I add random quantity of the product to the shopping cart
Then I see that number of products in the cart was updated

Examples:
| id |
| 1 |
| 2 |
| 3 |

另一种方法是破解运行器代码,但这只适用于您想要重复的单一场景。 How to execute same cucumber feature or scenario n times?

关于java - cucumber :循环场景中的步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58222920/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com