public
Description: BDD that talks to domain experts first and code second
Home | Edit | New

Feature-Coupled Steps (Antipattern)

Feature-coupled steps are steps that can’t be used across features or scenarios. This is evil because it leads to an explosion of step definitions, code duplication and high maintenance costs.

Example

An imaginary resume application could have the following features and step files:

features/
+--edit_work_experience.feature
+--edit_languages.feature
+--edit_education.feature
+--steps/
   +--edit_work_experience_steps.rb
   +--edit_languages_steps.rb
   +--edit_education_steps.rb

The edit_work_experience.feature could have the following scenario:

Scenario: add description
  Given I have a CV and I'm on the edit description page
  And I fill in "Description" with "Cucumber BDD tool"
  When I press "Save"
  Then I should see "Cucumber BDD tool" under "Descriptions"

The edit_work_experience_steps.rb could be implemented like this:

Given /I have a CV and I'm on the edit description page/ do
  @employee = Employee.create!(:name => 'Sally')
  @employee.create_cv
  visits("/employees/#{@employee.id}/descriptions/new")
end

How to fix

  1. Break up Conjunction Steps steps into individual steps.
  2. Organise steps by domain concept. See Step Organisation.
  3. Rename step.rb files to a domain-related name (rather than feature/scenario-related name).
Last edited by cosyn, Sat Jan 03 00:35:02 -0800 2009
Home | Edit | New
Versions: