Reputation: 67
We have multiple projects that use some common step definitions and page objects in the cucumber tests. I want to not duplicate such common stuff in each projects but would prefer having a way to share these between multiple projects.
Has anyone done such a thing before?
I am using Ruby.
Upvotes: 0
Views: 800
Reputation: 484
Shared steps could be packed as gem, and included as a dependency in both projects.
For example, we have a gem named 'common', which contains common.rb:
When(/^I share steps$/) do
puts "And I do!"
end
Then(/^I should be able to use it from another project$/) do
puts "seems ok!"
end
Then we could create features/step_definitions/common_steps.rb
in every dependent project, which consists of a single line:
require 'common'
Then we just use these shared steps like usual:
Feature: Sample
Scenario: Sample
When I share steps
Then I should be able to use it from another project
Upvotes: 1