Reputation: 68
Objective:- I want the data to be used across the steps in feature file. Its not in one step, Basically i want to run the scenario with all the data in example.
Scenario Outline:
Given my table for app1
Examples:
|data|
|123 |
|567 |
Scenario Outline:
Given my table for app2
Examples:
|data|
|123 |
|567 |
I don't want to copy the same Examples across the scenarios and features as it will require more rework if any data changes and plus it is not a good practice. How can I achieve this in spec flow
Upvotes: 0
Views: 1080
Reputation: 395
TL;DR It's not possible to share example tables across multiple features.
Explanation: The main objective of using feature files is readability. Scenarios have to be clear for all team members and should serve the documentation role. One table defined in one place and referenced in multiple feature files decrease scenario readabilities. You have to remember that defining scenarios != writing code and the rule 'DRY' should not be applied here.
If you're stubborn and just have to do that you can do the following:
Upvotes: 1
Reputation: 65
In my opinion, we should be make a function in Script folder to defineding or preparing data instead we make steps by steps to create data, it's manually and I don't like that. Example:
public class SpecFlowForFeatureSteps {
[Given(@"I create table by name (\.*)")]
public void ICreateTableByName(string tableName) {
// TODO something in there with table name
ScenarioContext.Current.Pending();
}
}
Thanks.
Upvotes: 0