I am new to Cucumber and the feature files it uses for BDD. I want to know if there is any way I could directly give the filepath of my external data file (eg. CSV file), and fetch the values of the parameters I use to create my test script.
Asked
Active
Viewed 2,266 times
4
-
See this http://stackoverflow.com/questions/21158660/using-csv-file-in-cucumber-watir-ruby/21158858#21158858 – Bala Jan 17 '14 at 13:52
-
2link is broken dude. – WenChao May 12 '16 at 06:54
1 Answers
1
You can add a tag with parameter to the features
@data("/path/data.json")
Scenario: Login as zinc admin
Given I open zinc homepage
And then create hook that reads the param and loads file before running a scenario.
Before do |scenario|
// read data from tag param
end

Nishant
- 4,659
- 2
- 27
- 43
-
-
can you please provide JSON structure or any article/link/post regarding same. if it require any more snippet kindly share that too – Shubham Jain Jul 03 '19 at 08:52
-
do you have a project on github ? I can help you by creating this logic. You will have to add a before hook, read tag value, and load data from the path – Nishant Jul 03 '19 at 09:00
-
see in before hook we can read data from excel that I already done. the problem is as the example data is out of feature it become scenario not scenario outline which run the scenario only one time. If i put loop in step definition function then if any one data example fails it failed the entire scenario which make it unreliable – Shubham Jain Jul 03 '19 at 09:09