黄瓜最佳实践:在示例表中添加列或添加步骤?

时间:2017-05-03 18:34:45

标签: 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 <price>
And the currency is <currency>
Examples:
| country | price | currency |
| England | 3     | Pound    |
| Spain   | 32    | Euro     |

一位同事写了这篇文章:

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    |

最佳做法是什么?

提前致谢。

1 个答案:

答案 0 :(得分:0)

首先避免情景大纲。他们所做的是浓缩步骤定义,这往往会隐藏您应该探索的不同内容。

其次尝试并清楚你正在做什么。据我所读,你可以说

  • 一个国家的人应该能够为其他国家/地区创建产品

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

  • 我想创建一个可以在许多不同国家/地区以多种不同货币销售的产品

这些事情在我看来是

  1. 同样有效
  2. 您可能想要或不想做的事情。
  3. 编写场景的全部原因不是为了推动测试,而是为了找出你想要做什么以及为什么它的重要性,以及清楚而无歧义地表达。

    所以对我而言,这两种情况都与最佳做法相差甚远,因为它们含糊不清,而且缺乏对WHAT和WHY的洞察力。

相关问题