使用Cucumber中的不同数据多次运行同一步骤
在执行其他步骤之前,我是否可以使用给定的数据(产品和状态)多次运行“给定”步骤?我在下面试过,但失败了使用Cucumber中的不同数据多次运行同一步骤,cucumber,Cucumber,在执行其他步骤之前,我是否可以使用给定的数据(产品和状态)多次运行“给定”步骤?我在下面试过,但失败了 Scenario Outline: Creating multiple products Given I have created multiple <products> that are at different <statuses> Examples: |products | statuses | |P1
Scenario Outline: Creating multiple products
Given I have created multiple <products> that are at different <statuses>
Examples:
|products | statuses |
|P1 | In Progress |
|P1 | Completed |
|P1 | Stopped |
When I have navigated to products page
Then I should see all products created
场景大纲:创建多个产品
鉴于我已经创建了多个位于不同位置的
示例:
|产品|状态|
|P1 |进行中|
|P1 |完成|
|P1 |停止|
当我导航到产品页面时
然后我会看到所有产品的创建
U正在混合使用场景大纲示例和数据表。示例表位于场景大纲的所有步骤下方
您可以改为使用DataTable并迭代它来创建对象
Scenario: Creating multiple products
Given I have created the following products
|products | statuses |
|P1 | In Progress |
|P1 | Completed |
|P1 | Stopped |
When I have navigated to products page
Then I should see all products created
@Given("I have created the following products")
public void createMultipleProducts(DataTable data) {
//Iterate the data and create each product
}