我对 BDD 比较陌生,我有一个关于场景大纲的问题。在互联网上查看样本时,我感觉占位符可以采用任何值。其域中的元素数量不受限制。这是一个例子:
Scenario Outline: eating
Given there are <start> cucumbers
When I eat <eat> cucumbers
Then I should have <left> cucumbers
Examples:
| start | eat | left |
| 12 | 5 | 7 |
| 20 | 5 | 15 |
例如,占位符<start>
可以是任何数字,因此值的数量是无限的。
在我的规范中,我必须处理可能具有四种状态之一(计划、正在进行、暂停和关闭)的合同。我的规范说我可以编辑计划中的合同,但我不能编辑具有其余三个状态之一的合同。
我想我会写一个名为“更新计划合同”的场景和一个场景大纲,其中合同的状态是占位符。
Scenario: Update a planned contract
Given the list of contracts as follows
| name | status | some value |
| c1 | planned | 123 |
And I have edited contract c1 as follows
| field | value |
| name | c1 |
| some value | 456 |
When I save contract c1
Then the list of contracts should be as follows
| name | status | some value |
| c1 | planned | 456 |
Scenario Outline: Update contract
Given there is a <status> contract
And I have edited that contract
When I save that contract
Then I an error 'only planned contracts are allowed to change' should be displayed
Examples:
| status |
| ongoing |
| paused |
| closed |
那是正确的方法吗?一个显式场景和一个参数化?或者我应该将场景大纲写成每种可能性的明确场景?我不确定,因为与互联网上的示例相反,合同的状态受到四个可能值的限制。