Fork me on GitHub

Use 'Background' to consolidate common steps in a feature

27 Jul 2010

Ng Tze Yang

Before:

Scenario: Accessing create post page
  Given I am already signed in as "flyerhzm"
  When I follow "Submit"
  Then I should see "Share a Rails Best Practice" page

Scenario: Successful create with valid info
  Given I am already signed in as "flyerhzm"
  And I follow "Submit"
  And I fill in the following:
  # (more steps)

After:

Background:
  Given I am already signed in as "flyerhzm"
  And I follow "Submit"

Scenario: Accessing create post page
  Then I should see "Share a Rails Best Practice" page

Scenario: Successful create with valid info
  Given I fill in the following:
  # (more steps)

Tags