Thomas Sundberg

October 23, 2014

An email marketing system built using test first and Cucumber-JVM

This post is available at


  1. Thank you for this great tutorial!

    I have one problem when following the instructions: my test fails with “Duplicate step definitions” because of the method i_should_get_an_error_message() that exists in both UnsubscribeSteps and SubscribeSteps. If I remove the method from UnsubscribeSteps my test will also fail because the message will not be set as expected.

    It works if I put all step definitions in the same class or if the wording of the feature is changed so as to avoid duplicates but I guess that you would want to reuse steps sometimes and that there are nice ways of doing it?

    Comment by Erik Dybner — October 25, 2014 @ 00:12

  2. Hi Erik!

    The error you got comes from the fact that all steps are global in Cucumber.

    I had some problems understanding why you got this problem, I couldn’t find the duplicate step. So I looked at the source I have at GitHub, which I know was executed while I wrote the example at JDD. It turns out that I don’t have two steps that are the same. I have expressed the same thing in two different ways and didn’t realize it until now. I used the wordings “should I get an error message” in the SubscribeSteps and “I should get an error message” in UnsubscribeSteps. This is obviously two ways to say the same thing and the this step should probably be reused instead of re-implemented.

    Your solution, placing all steps in the same class is obviously one way of avoiding duplication.

    I expect that this problem would have been found if I had had a partner to write the code with. Now I didn’t and the result are bugs like this.


    Comment by Thomas Sundberg — October 25, 2014 @ 07:53

    • Thanks for the clarification. Now that I have downloaded half the Internet I might as well do this right 😉

      Comment by Erik Dybner — October 25, 2014 @ 23:57

      • Do it right sounds like a great idea.

        But I think that you have done it at least partly right since you found the ambiguity in the scenarios.


        Comment by Thomas Sundberg — October 26, 2014 @ 19:43

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: