I’m using cucumber-watir-webdriver with for automation purposes. I have the following directory structure:
|features
-|feature1
--|1.feature
--|step_definitions
---|1.rb
-feature2
--|2.feature
--|step_definitions
---|2.rb
and so on. I need to know what is best practice to reduce redundancy in 1.rb and 2.rb.
feature1 and feature2 are completely different so I cannot combine both in one directory.
Also there is some part where feature line is same but execution in steps is different so it will create ambiguity if they are together.
I need to know if there is some part common in 1.rb and 2.rb where should I put it is there best practice to keep common step definitions.
Cucumber only searches for step definitions in current or following directories.
So we can not have common step definitions directory or file below two feature directories,
I found one solution to this as
now to load this step definition add
in your 1.rbs.
also you can have longer directory structure then you can keep common_steps.rb file in every such directory containing common steps of following features and you can require previous common_steps.rb file with–
this code.
This will keep your directory structure and step_definition files clean