Syntax 小黄瓜,如何编写一个有可选给定步骤的场景?
我正在编写一个简单的添加项场景。此项具有必填字段名称、编号、日期,并且该项具有可选字段类别、说明。如何指定字段:Syntax 小黄瓜,如何编写一个有可选给定步骤的场景?,syntax,gherkin,Syntax,Gherkin,我正在编写一个简单的添加项场景。此项具有必填字段名称、编号、日期,并且该项具有可选字段类别、说明。如何指定字段: scenario: add item given name and number and date but category is not null and description is no null then save item 这是对的吗?我会将其分为多个场景,因为每个场景都应该测试一件事情 此外,你应该始终有一个When步骤。给定是一
scenario: add item
given name
and number
and date
but category is not null
and description is no null
then save item
这是对的吗?我会将其分为多个场景,因为每个场景都应该测试一件事情 此外,你应该始终有一个When步骤。给定是一个先决条件,并不总是需要,什么时候是一个行动,什么时候是该行动的预期结果。如果没有一个步骤,你是说你有一个什么都不做的预期结果 我会将功能文件编写为如下内容:
Feature: Add Item
As a stock control manager
I want to be able to add items to an inventory
So that I have a catalogue of al items in stock
Business Rules:
- Name, number and date are mandatory data
- category and description are optional
Sceanrio: Add item witout category
When I add an item without a category
Then the Item will be saved
Sceanrio: Add item without descritpion
When I add an item without a descritpion
Then the Item will be saved
Sceanrio: Add item without name
When I add an item without a name
Then the item will not be saved
And I will be informed the name is maditory
Sceanrio: Add item without number
When I add an item without a number
Then the item will not be saved
And I will be informed the number is maditory
Sceanrio: Add item without date
When I add an item without a date
Then the item will not be saved
And I will be informed the date is maditory
为了完整起见,您可能还需要添加一个包含所有数据的场景。