Reputation: 817
I'm writing a simple add item scenario. This item have required fields (name, number, date) Also that item have optional fields (category, description). how i can specify the fields:
scenario: add item
given name
and number
and date
but category is not null
and description is no null
then save item
Is this right?
Upvotes: 0
Views: 923
Reputation: 59
I would split this into multipal scenarios, as each scenario should test one thing.
Also you should always have a When step. Given is a precondition and not always needed, When is an action and Then is the expected outcome of that action. Without a When step you are saying you have an expected outcome of doing nothing?
I would write the Feature File to be something like the following:
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
Upvotes: 1