Reusing Cucumber Steps
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
Leave a Comment