Reputation: 79
I am currently working with Specflow with c#. I have two feature files with the exact same table/data in the background. Also within both feature files, I have scenarios which cannot be merged into one feature file (they need to remain in two separate files).
Now, what I am trying to do is extract the background table from both classes and put it in it's own class in order to keep from having to edit/keep track of two different tables (they are fairly large) .
Is there a way that I can reference just a background from two different feature files as if the feature files had the background themselves?
Thanks!
EDIT: Currently, I have the following
FEATURE_1 FEATURE_2
| |
BackgroundTable Same BackgroundTable
| |
Scenario_1 Different_Scenario_1
Scenario_2 Different_Scenario_2
. .
. .
I want to change it so that I can have
FEATURE_WITH_ONLY_MASTER_BACKGROUND
|
BackgroundMasterTable
.
.
FEATURE_1 FEATURE_2
| |
ReferenceToMasterTable ReferenceToMasterTable
| |
Scenario_1 Different_Scenario_1
Scenario_2 Different_Scenario_2
. .
. .
. .
Upvotes: 0
Views: 431
Reputation: 8120
One method for this is to use a BeforeFeature hook to call your Given..() step to set up your background table and save it to FeatureContext.Current, and then apply that hook via an attribute to each of the features that need that table.
Upvotes: 2