Reputation: 22264
I'm new to SpecFlow and BDD and I've hit a roadblock in writing a scenario that requires a user to make a choice. Essentially here is the scenario:
Scenario: Deleting a record
Given I am on the edit record page
And I click the delete button
Then I should see a prompt asking for confirmation
I'm not sure how to proceed beyond this point. There are two paths to test here, one for when the user says "OK" to the confirmation, and one for when the user says "Cancel".
I want to say "And If I click OK" followed by "Then the record should be deleted", etc. But it seems like it should be broken up a better way.
How would you reword this scenario?
Upvotes: 0
Views: 626
Reputation: 760
There might actually be three scenarios here. The first one focusses as Marcus suggests:
Given I am on the record page
When I delete a record
Then I should see a confirmation message
But are there also scenarios for the behaviour of the confirmation dialog?
Given I am presented with a confirmation message
When I confirm the action
Then the action proceeds
And
Given I am presented with a confirmation message
When I cancel the action
Then the action does not proceed
Upvotes: 2
Reputation: 4822
I would recommend writing your scenarios on a higher level. Avoid buttons, clicks and textboxes in your scenarios and try to talk about what the user want to accomplish - the behaviour of your system. The actual interaction with the page is then hidden in the step definitions.
So in your case that will be something like;
Given I am on the record page
When I delete a record
Then I should see a confirmation message
In the step definition for [When("I delete a record")] you then implement the clicking on the delete button and the Ok-button for "are you sure" or whatever is needed to delete the record.
I hope this was clear. Wrote it on my phone ;)
Upvotes: 3