AravindhanBoss
AravindhanBoss

Reputation: 3

Only keeping Then , can i have a separate scenario in gherkin

Can i have separate scenario without Given and When steps, if you see last scenario, i have only then step as a separate scenario is it valid? my feature file is about, i need to login to the application and i need to schedule a maintenance for 35 min, at 30th minute i will get count down timer. Respectively i will get countdown time at 5,4,3,2 and 1 minutes. After verifying timer automatically application logs out and i need to verify whether i am in maintenance page

Scenario: Notification displayed 30 minutes before start of the maintenance Given user is in "Home" page Then system displays maintenance notification 30 minutes before logging out of the system

Scenario Outline: Notification displayed minutes before start of the maintenance When user closes the maintenance notification Then system displays maintenance notification minutes before logging out of the system

Examples:
  | time |
  | 5    |
  | 4    |
  | 3    |
  | 2    |
  | 1    |

Scenario: Maintenance page is displayed Then system logs the user out of the system after maintenance starts And system displays "Maintenance" page

Upvotes: 0

Views: 145

Answers (1)

Thomas Sundberg
Thomas Sundberg

Reputation: 4343

There are no technical reasons to have the keywords Given When Then And or But in Gherkin. You can replace all of them with * and Cucumber will execute the steps in the order they are specified in the scenario.

So the answer to your question is, yes it is legal to only keep the Then step.

The follow up question is now, is it a good idea? The answer is probably, it depends. It depends on your audience that reads the scenario and expect to understand how the system is supposed to work. Will they be able to do so and have confidence that it is correct? Only your audience can answer that question so I would suggest that you ask them during a demo or similar session.

Upvotes: 0

Related Questions