Search code examples
cucumbergherkin

Is it ok to use empty lines between gherkin test steps?


Our team are reviewing some conventions and need some guidance. So people would like to have separation between the setup (represented by the Given statement) actions (When) and assertions (Then). Is it ok to use empty lines between gherkin test steps?

What would be the cons of this approach? Because on the cucumber website there is no rule to not do this.

Feature: Example
Scenario: Multiple Givens
  Given one thing                  <- Setup
  And another thing
  And yet another thing

  When I open my eyes              <- Action

  Then I should see something      <- Assertion
  But I shouldn't see something else
 

Solution

  • You can use empty lines, but I don't think you ever should. Basically if you need the empty lines to make your scenario readable then you should rewrite your scenario to be readable without the empty lines.

    The empty lines are a crutch to support scenarios that are too long and haven't had enough work done on them to make them clear and succinct.