Why I stopped using Pickle with Cucumber

…no, not because it leaves a bitter aftertaste, I’m talking about the Pickle step definitions for Cucumber.

I have lately been using Pickle when writing Cucumber features, however I have come to the conclusion that this is a bad idea. The reason being that when using Pickle, you create entries directly, whereas the whole point of Cucumber is that it is for high level integration testing.

What I do now, is to create any entries by filling out and submitting the relevant forms with a step definition, for example I may have the following:

Given an admin has created the following products
  | Name    | Variants                                  | Featured |
  | T-Shirt | Small: 10.99, Medium: 12.99, Large: 14.99 | Yes      |
  | Keyring | Default: 2.99                             | Yes      |

I would then write a step definition for this that would log in as the admin user, break this table apart and fill in the relevant forms.

I would go so far as to say that using factories at all in features is a bad idea and instead everything should happen via the user interface for better coverage. For any data that is known to exist when the app is deployed via ‘rake db:seed’, this can be loaded in the ‘env.rb’ file e.g.


load 'seeds.rb'

Update 11/2/2010: Sometimes this is simply not practical due to slowdown which is a shame, as noted by Amos in the comments.

Published by

Jamie

Hi, I am the Managing Director of SonicIQ Limited in the UK. I have been working in the web development industry since 1999 and have been running SonicIQ since 2001. Currently Ruby On Rails is my preferred development platform. I am experienced in designing with web standards, HTML5, CSS3 and Javascript.

4 thoughts on “Why I stopped using Pickle with Cucumber”

  1. If you already have the adding of that data tested in another cucumber test then you are just slowing down your tests by doing continuing to add that data through the ui every time.

  2. @amos Thanks for your comment and this is very true, however I have been setting up the entries I need in the “Background” of a feature. I’m assuming this only gets run once per feature file and gets rolled back per scenario, I may be wrong.

    I am not too concerned about the loss in speed in any case as I have my unit tests which run fast. Also, if I decide to move from ActiveRecord to MongoMapper for example (or even from Rails to PHP), I won’t have to touch my features and risk changing their validity.

    I suppose it’s a toss up between speed and flexibility. In my case I have not found speed to be too much of an issue. I will report back if this starts to become an issue.

  3. I agree with Amos. Pickle is used with Cucumber to setup your environment (background) to run your test against.

    If you need five users to test your social platform search and match feature, you won’t have five users sign up, read their email and confirm their account all the time?

  4. @Ariejan. Agreed, my original thinking was that this would remove the dependency on ActiveRecord or any ORM/language and you could in effect rewrite you entire app in another language from your features, however in practice this is not feasible due to slow down this brings.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>