Is there a way to run a cucumber scenario multiple times over a list of dynamically generated data?

StackOverflow https://stackoverflow.com/questions/22518609

  •  17-06-2023
  •  | 
  •  

Question

For example, I have a list of ids for a product that lives in a database and is updated daily. I need to be able to run a scenario that consumes that data and runs the same steps over each of the ids in order. However, the test should not stop because one of the ids failed in the scenario, similar to what cucumber does with the scenario outline type of tests.

We would also want to format the output of the cucumber test(s) so that each id is formatted as if it is a separate test or example in a "scenario outline."

Was it helpful?

Solution 2

Cucumber is not designed to write complex information in feature file , If your Data is complex , or dynamically generated , you should get Data in step definition and write a generic term in feature file .

That's the intention of cucumber , writing simple features so that non technical person can easily understand what the scenario is doing.

OTHER TIPS

I believe I did something similar some time ago. Have a look at this feature definition.

The "Then I should be able to get to the browse categories page" action is defined here and, as you can see, Category at line 59 retrieves data from this class. In this case I'm getting data from a CSV file, but you can just substitute it with your DB.

My Ruby is a bit basic so the code style might not look so good, but it is an example I had around to easily explain what I did. Hope this help!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top