Cucumber最佳实践:在示例表中添加列还是添加步骤?

Cucumber最佳实践:在示例表中添加列还是添加步骤?,cucumber,scenarios,Cucumber,Scenarios,我必须通过BDD方法在不同的国家测试产品的创建。我用的是黄瓜 我必须提到的是,货币不是强制性的创造,它是与国家挂钩的 我编写了以下测试: Scenario outline: I am able to create a product in different countries Given a product that costs <price> in <country> When I create this product Then the price is <p

我必须通过BDD方法在不同的国家测试产品的创建。我用的是黄瓜

我必须提到的是,货币不是强制性的创造,它是与国家挂钩的

我编写了以下测试:

Scenario outline: I am able to create a product in different countries
Given a product that costs <price> in <country>
When I create this product
Then the price is <price>
And the currency is <currency>
Examples:
| country | price | currency |
| England | 3     | Pound    |
| Spain   | 32    | Euro     |
场景大纲:我能够在不同的国家创建产品
给出了一个成本很高的产品
当我创建此产品时
那么价格是多少
货币是
示例:
|国家|价格|货币|
|英格兰| 3 |英镑|
|西班牙| 32 |欧元|
一位同事写道:

Scenario outline: I am able to create a product in different countries
Given a product that costs <price> in <country>
When I create this product
Then the price is <price>
And the currency is Pound if country is England
And the currency is Euro if country is Spain
Examples:
| country | price |
| England | 3     |
| Spain   | 32    |
场景大纲:我能够在不同的国家创建产品
给出了一个成本很高的产品
当我创建此产品时
那么价格是多少
如果国家是英国,货币是英镑
如果国家是西班牙,货币是欧元
示例:
|国家价格|
|英格兰| 3|
|西班牙| 32|
最佳做法是什么


提前感谢。

首先,避免场景概述。它们所做的是压缩步骤定义,这往往会隐藏您应该探索的不同内容

其次,试着更清楚地知道你在做什么。从我读到的你可能会说

  • 一个国家的人应该能够为其他国家创造产品

  • 来自不同国家的用户应该能够创建产品

  • 我想创造一个产品,可以在许多不同的国家和许多不同的货币销售
在我看来,这些东西是

  • 同样有效
  • 你可能想做或不想做的事情
  • 编写场景的全部原因不是为了驱动测试,而是为了找出您想要做什么以及为什么它很重要,并清楚地表达这一点而不含糊

    因此,对我来说,这两种场景都离最佳实践相去甚远,因为它们模棱两可,并且缺乏对“是什么”和“为什么”的洞察