I'm using cucumber (and writing tests in gherkin) in a JS/Node project, and I've found myself duplicating lots of test data (Scenario Outline examples) in different examples.
Most of the cases is using a list of users with different properties which need to be used to ensure that different parts of a webpage work for all of them.
Therefore tests end as something like this:
Scenario: s1
Given xxx
Then yyy <field1>
Then zzz <field2>
Examples:
| username | field1 | field2 |
| user1 | f11 | f21 |
| user2 | f12 | f22 |
Scenario: s2
Given xxx
Then yyy <field1>
Then zzz <field2>
Examples:
| username | field1 | field2 |
| user1 | f11 | f21 |
| user2 | f12 | f22 |
As you can see, examples for scenarios s1 and s2 are the same... so I thought it would be a good idea to load them from a external file, making it easy to share across scenarios/files (this is just a simple example with 2 scenario, but think about a real app with lot of features).
If the data for a user is updated it means I'd must update all of the examples... while if I just load it from an external file it would be only one place to update.
I've seen that some sites provide that feature, such as here, but couldn't figure how to do it on my own to have something like:
Scenario: s2
Given xxx
Then yyy <field1>
Then zzz <field2>
Examples: {"dataFile":"./users.csv"}
There are always alternatives like, pre-processing .feature files and replace those lines with the content of the files or something like that... but I was wondering if there's something more native or direct, as I don't want to go to that path, or heavy-customization...
I couldn't find anything so anything would be welcome.