Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6359807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:34:05+00:00 2026-05-24T23:34:05+00:00

In Cucumber you define steps which define your BDD syntax; for instance, your test

  • 0

In Cucumber you define steps which define your BDD syntax; for instance, your test might have:

When I navigate to step 3

and then you might define a step:

When /^I navigate to step (\d+)$/ do |step_number|
   # navigate to step ${step_number}
end

Now, all of the above works perfectly fine as is (or at least I think it does). However, you can also do this instead:

When I navigate to step "3"

with a regex:

When /^I navigate to step "(\d+)"$/ do |step_number|

In “The RSpec Book: Behaviour-Driven Development with Rspec, Cucmber, and Friends”, author David Chelimsky writes “There are two common styles for steps … Discuss the pros and concs with your team”. On my team a few people have already started using quotes, but it makes invoking steps manually more awkward because you have to escape the quotes inside the step step names (when those step names are themselves wrapped in quotes). However, having quotes makes it more clear where variables are in the Cucumber text.

So, what I’m wondering is: is there any sort of community consensus on what the “right” style is here? Or lacking that …

  • Has anyone ever done a benefit comparison between the two styles?
  • Has anyone used either style extensively?

Ideally I’d like to find out as much as I can before we write a million tests with the “wrong” style 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:34:05+00:00Added an answer on May 24, 2026 at 11:34 pm

    Seeing as no one is replying to you, I decided to comment – maybe you’ll find my opinion helpful.

    For example I’ve been using both styles extensively on a project where there was no “should do this way” in this matter. I think I ended using “(\d+)” style more, because of, like you said:

    having quotes makes it more clear where variables are in

    As for constructing steps that are composed of other steps, I usually did:

    Then /^I fill in my profile information with: "(.*)\/(.*)\/(.*)"$/ do |display_name, picture, description|
        And %{I fill in "user_display_name" with "#{display}"}
        And %{attach the file "#{picture}" to "user_picture"}
        And %{I fill in "user_short_description" with "#{description}"}
    end
    

    Hope that helps, I am open for discussion 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting started with cucumber, and I have written the following step definition, which
When i run cucumber it displays the possible steps that i should define, an
I'm using cucumber and selenium for integration testing and have defined a cucumber step
In Cucumber, I'm trying to create a step like this: Then I should see
I have a cucumber step that recently started failing when an   was added
I have defined this step: Then /^the ([^]*) field(?: within (.*))? should be empty$/
I'm trying to write a Cucumber scenario that requires me to have a logged
I've been having trouble using cucumber and webrat to test authlogic-openid authentication in a
I'm new to rails and cucumber and I'm trying to test the following scenario
I'm looking at a cucumber test suite that is somewhat brittle right now; many

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.