[rspec-users] [Cucumber] Feature vs. Scenario

Lenny Marks lenny at aps.org
Thu Mar 19 12:44:04 EDT 2009


I'm curious what other people's thoughts are about when to use  
Features vs. Scenarios and how much it matters. I'm getting the sense  
that the line is a thin one, and has more to do with complexity/time  
to develop than anything else. I had originally enforced a fairly  
rigid definition of 'Scenario' to represent a particular  
variation(e.g. sufficient funds, insufficient funds), but lately I've  
been seeing a lot of examples where the scenario is more like a mini- 
feature.

ex. Mini-feature style

Feature: Create a new correspondence to an author

Scenario: Caution users about sending 'questionable' types of  
correspondence

Scenario: Lock manuscript before creating correspondence

These scenarios are each distinct things so to me are 'features' in a  
way but they may also be trivial to implement, so using any kind of   
'a feature should generally take n days/weeks to implement' guideline  
would make that smell. Also, just because it might be trivial to  
implement doesn't mean that I don't want to attach some context/ 
justification for documentation purposes....

ex.

Feature: Create Correspondence /  Caution before creating  
'questionable' types of correspondence
   In order to help avoid sending embarrassing letters
   Users should be forced to confirm they want to proceed
   before being able to create a correspondence deemed 'Questionable'  
by nature of its type
...
Feature: Create Correspondence / Check for locks
	In order to prevent invalid information from being sent out
	I should not be able to create a new correspondence
	when a lock has been placed on the manuscript

It used to be possible to have multiple features per file so feature  
vs. scenario could boil down to: Use feature if you want to annotate.  
This is no longer the case and I'm not convinced that was a good idea  
anyway. I guess that could still be accomplished by organizing  
features via directories  or maybe tags.

create_correspondence/
      caution_questionable.feature
      check_locks.feature

Another style related thing I can't decide on is what my scenarios  
should ideally represent.

One style is to use the scenario title as the 'what' and the Given/ 
When/Thens as the proof(acceptance test)

Scenario: Reject when account has insufficient funds
Given I have an account with $10
And I attempt to withdraw $20
Then I should have $10 in my checking account
And I should see 'Insufficient funds'

Another style is to use the Given/When/Then as the 'what'

Scenario: Insufficient funds
Given I have an account with $10
And I attempt to withdraw $20
Then I should have $10 in my checking account
And I should see 'Insufficient funds'

I find myself leaning toward the former most of the time. This was a  
bad example(too simple), but I find the latter style tends to blur the  
goal a bit.

Thanks
-lenny


More information about the rspec-users mailing list