我需要編寫一個類來強制執行有關可能會或可能不會添加到倉庫中相同容器的項目的規則,並且我希望在實現它之前將要求轉換爲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
任何指導意見?