We have this feature with multiple resolutions to test. We need to use this list of resolutions to test hundreds of sites and so would like to be able to reference the list and be able to maintain it from one file.
Feature: Navbar
Verifies that navbar items are displayed in commonly used desktop display resolutions.
Scenario: Verify navbar is displayed correctly in commonly used desktop resolutions
Given I navigated to site
When I view site at desktop resolution <resolution>
Then logo is displayed at start of navbar
And navbar parent menu items are displayed in navbar
Examples:
| resolution |
| 2560x1440 |
| 1920x480 |
| 1600x900 |
| 1536x864 |
| 1440x900 |
| 1366x768 |
| 1280x1024 |
| 1280x720 |
Is there a way to reference this Examples list from a different feature? Is there a better way to do this?
We are using SpecFlow in .NET 6 with Selenium.
The SpecFlow External Data Plugin was designed precisely for this kind of testing. It allows you to separate examples from scenarios and reuse those examples across feature files.
Roughly this is the process:
Create a CSV file with the example data in your scenario. Make sure columns in the CSV file match the
<tokens>in your scenarios.Reference the CSV file in a tag before the scenario name:
I'm sure there is some setup to use this plugin. Refer to the official SpecFlow documentation I linked to above for those specifics.
Note that this largely replaces the SpecFlow+ Excel plugin, which was only available for older SpecFlow 2.x versions. SpecFlow v3+ should convert to the external data plugin.