我需要编写一个类来强制执行有关可能会或可能不会添加到仓库中相同容器的项目的规则,并且我希望在实现它之前将要求转换为Cucumber。每件商品有几个属性,例如“商品系列”(例如:电子产品,书籍),“商品状态”(例如:主要库存,缺货库存)和“批次”(例如:1050,1051)。哪里摘要Cucumber步骤正确?
我能想到的几个策略编写黄瓜测试这一点,我想知道这是建议的一个:
首先,你可以列举所有单位产品的属性:
Given I have a tote containing:
| sku | client | family | status | batch | weight |
| 100000 | Foo | garment | main | 1234 | 10 |
When I add the item:
| sku | client | family | status | batch | weight |
| 200000 | Bar | garment | main | 1234 | 10 |
Then I should be told there is a Client conflict
其次,你可以有一个基本的产品硬编码,并尝试指定最小从它不同的属性:
Given I have a tote containing an item that's client "Foo"
When I add an item that's client "Bar"
Then I should be told there is a Client conflict
这是假定DEF步骤initions包含基本属性,并在步骤中提及属性时覆盖它们。
最后,你可以去抽象的另一步骤:在这里正确的做法
Given I have a tote containing an item
And I add an item with a different client
Then I should be told there's a client conflict
任何指导意见?