Get data from Data Files in feature file


Hi everyone,

Can you guys help to let me know it’s possible to get data from Data Files like sql database for example Capture

I want to get list users from my database




There are many ways you can read data from feature file. You can convert to Map, List , Maps, Lists and iterate through.

You an get complete details how to implement it at my blog.

Let me know in case of any query.



Thank you so much Priyank @,

What I mean is I don’t want to hard code the test data.

I want to get it dynamically. I will get email from database for example



Ohh I see. Sorry I misunderstood. I don’t think so we can have such configuration with respect to feature file. It is just static gharkin syntax. I have not seen such example. Other way, what we can do (In case you need data from DB) then we need to have such implementation within the code which will establish DB connection , fetch data and parse within the test.

Only disadvantage is - test data can’t be seen/part of feature file. But you can still write such data explicitly to cucumber report using scenario.write()

I am not aware if any other effective method exists!

  • Priyank