Skip to content

Reusing Cucumber Steps

November 24, 2010

Reusing Steps or calling Steps within steps.

Suppose you have:

Given a author exists with name: "author1"
And a post: "My post" exists with author: the author, title: "my title"

It can be compressed into one step with the step like

Given a post: "My post" exists by author: "author1", title: "my_title"

And added step definition

Given /^a post: "([^"]*)" exists by author: "([^"]*)", title: "([^"]*)"$/ do |post, author, title|
    Given "a author exists with name: \"#{author}\""
    And "a post: \"#{post}\" exists with author: the author, title: \"#{title}\""
end
Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: