[rspec-users] [Cucumber, BDD] When not to use Cucumber?
jonathan at parkerhill.com
Sat Jan 24 12:44:17 EST 2009
I've been using cucumber, and story runner before that since plain
text stories were introduced 1.5 years ago. I also use rspec for
model and controller specing/testing. I'll answer the opposite
question: when do I use cucumber?
I am a team of one, and I am my own client, so the way I use cucumber
may be different than other people's experience. As outlined in my
recent presentation (http://www.slideshare.net/linoj/cucumber-how-i-
slice-it-presentation-924254 ) I've found myself using cucumber for:
* Talking to myself (planning)
* Keeping track of what I'm working on (outlining)
* Automating my manual testing (scripting)
* View specs
* Regression testing (confidence)
Plain text stories let me plan out my app from the end-user point of
view. When I'm my own client, Given/When/Then helps me structure
conversations with myself. Scenarios let me explore variations.
However, I do not shoot for full coverage or many edge cases, I leave
that for the controller and model specs. These tend to be short
atomic G/W/T scenarios.
When taking the BDD approach (which TBH is sometimes), it can take
days to implement a single scenario, drilling down from feature to
controller spec to model spec, etc, at which point the story provides
a valuable context for what to work on next as i "pop the to-do
stack" and work my way through the steps.
However, in reality, sometimes I jump in and implement stuff first,
and test it as I go by clicking in the browser (oh my!). At a certain
point I'm repeating the same set of clicks so I write a cucumber
story to more easily script the scenario. In this case there may be a
high level Given step(s), and a sequence of multiple When's, with a
few Then's inbetween (to validate where I landed, flash messages, or
I've also started using cucumber in place of view specs. These
scenarios will often be a simple Give/When with a whole bunch of
Then's that validate elements on the page.
By the way, I've written utility steps for viewing the response in a
browser (http://www.vaporbase.com/postings/Show_me_the_response ),
and I often use rdebug to work through my code.
Finally, I love to run my suite of scenarios as regression tests,
especially at stabilization points in my development, to make sure
everything is still operational. I even have a "cap deploy:features"
to run them on my staging server.
wtf <=> ftw
More information about the rspec-users