4

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.

realnikunj
  • 101
  • 1
  • 5

1 Answers1

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
  • Could share Java code snippet better way to understand this – Pavan T Oct 27 '18 at 03:48
  • 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