Jenninha
Jenninha

Reputation: 1377

BDD parameters in a feature context?

I am writing a feature that will have scenarios with a parameter in common. The step would be something like this:

Given the user is viewing the book <bookIdAdress>
When ...
Then ...
Examples:
     | bookIdAddress |
     |    ...        |
     |    ...        |

I will have many scenarios like the above in my feature. And I want to test this feature with many books.

This same parameter would repeat for all scenarios of a feature. As far as my current knowledge of BDD is concerned, the only way is to keep putting the same examples in every single scenario. I was wondering if there was an option to have the Examples written once for the entire feature, or if I am completely wrong in doing it this way, what approach should I take?

I know I can use the Background tab to write a set up for the entire feature, but I don't know an option to just put the examples in a feature context only.

Upvotes: 2

Views: 719

Answers (1)

Brantley Blanchard
Brantley Blanchard

Reputation: 1218

You can not share example tables in SpecFlow. I tried by adding the table to the background as a way to hack it but it didn't work.

One option to consider is telling each Scenario to get data from the same excel file. Then you can share a data source as well as hide long tables of data.

http://www.specflow.org/plus/Excel/

Upvotes: 1

Related Questions