views:

2170

answers:

7

I'm trying to really understand Cucumber stories. I get it, but I'm really slow writing them. I think if I saw a good fleshed out application, I'd get closer to where I want to be.

There are some samples out there, but there aren't any I can find with a single app with some non-contrived example stories.

Are there any existing ones?

+9  A: 

I can't point you to any great examples out on the web at the moment, aside from Aslak's cucumber wiki on github. I can tell you a little bit about how our cucumber style has developed.

In our experience there are two main directions you can follow with cucumber stories. The path on which we started with was high-level implementation-independent user-story-style steps. For example:

Given the user has entered an email address that belongs to an existing user
  And the user supplies the correct password
 When the user attempts to sign in
 Then the system signs the user in
  And the system displays the welcome page
  And the system displays an indication that the user is signed in

As we've evolved our use of cucumber, we've moved away from this style (which lends itself to the feature-coupled steps anti-pattern) towards a more user-interface-specific set of steps that relies as much as possible on the pre-defined webrat/culerity steps. For example:

Given I fill in "Email" with "[email protected]"
  And I fill in "Password" with "tr33fr0g"
 When I press "Sign In"
 Then I should see "Welcome, Kaspar"

The advantage of the former style is that it can be written without any knowledge of the interface, and is relatively robust in the face of interface changes. The advantage of the latter style is that it feels less prone to analyst writer's block and makes it even more unambiguous how exactly to proceed as a developer writing code.

Lakshan Perera's Extended Bort revision of the Bort example app includes the cucumber plugin, but unfortunately no examples.

I'm hopeful that the RSpec book forthcoming from Pragmatic Programmers will provide some fleshed out examples.

Abie
A: 

I don't see much value in Cucumber unless you have business analysts who are capable of writing the tests.

Otherwise it is yet another level of tests that need to be managed and maintained. Each step needs to be mapped to an actual low-level test that does the work.

Toby Hede
Cucumber enables an Acceptance Test-Driven Development process by dramatically improving the value of functional specifications (that you should be writing anyway) and closing the gap between users, business analysts, testers and developers. It's a revolutionary tool that requires a new mindset for all those involved in the development process in order to be effective.
Dema
Wow ... people hate this comment. I stand by it though. If you don't have analysts then cucumber is an extra layer on top of your functional tests.
Toby Hede
I'm upvoting even though I disagree with you. In my personal work, I find cucumber very useful for getting out of the low-level mindset and thinking about what I'm trying to achieve. (In other words, I sometimes act as my own BA).
Grandpa
I agree with you on that point. And, to be honest, I've started doing much the same thing myself since I originally wrote this comment.I don't test everything, but I use it to help myself reason about what I am doing. In my day job we have dedicated BA and QA resources, so we use cucumber a lot.
Toby Hede
+2  A: 

I am just starting with Cucumber too. I found this Rails cast to cement a few of the really basic ideas for me: http://railscasts.com/episodes/155-beginning-with-cucumber

Rodreegez
A: 

On the Cucumber WIKI there's a link to a couple of sample projects where you would find their features in the 'features' directory.

I used features found in those projects to get started.

Peter Theill
+1  A: 

The bostonrb.org site is open source and also uses cucumber: http://github.com/bostonrb/bostonrb/tree/master

hgimenez
+1  A: 

The Clearance authentication plugin (http://github.com/thoughtbot/clearance) from thoughtbot includes a suite of cucumber stories and a generator for bootstrapping them into your application. I've found this to be really valuable in getting started with cucumber (plus it's a good authentication plugin).

samg
A: 

check this out http://github.com/jschoolcraft/urlagg