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 步骤。Given 是一个先决条件,并不总是需要,When 是一个动作, Then 是该动作的预期结果。如果没有 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
推荐阅读
- reactjs - 在 reactjs 中使用带有 useState 钩子的回调
- javascript - Accessing object property through bracket notation regardless of the number of brackets
- python - 类内部的函数,即方法
- python - Get Text from h1 with BeautifulSoup
- web-frameworks - Is there a web framework for kotlin native
- python - 比较忽略某些字符的行与 difflib
- python - How can I add custom fields when creating a sign up form using Django form?
- opentext - How to download a LiveLink (OpenText) file using REST API and .Net (C# /VB)
- koin - Koin - 每个参数值的单个实例
- c - C 编程 ncurses 在多个窗口上的颜色不起作用