A background is a place for shared data like this, until the data gets too large and your background section spans several pages. It seems like this could be so.
You specify tables with 20 + rows each and having multiple data tables like this. That would be a lot to get readers to get to the Scripts. Is there any other way to describe the data? When I had data tables like this in the past, I put the parts in the instrument class in the automation code and then described only the important aspects in the Feature file.
Assuming, as an example, that βTomβ is a potential buyer of cars, and you are managing a car dealership, then its data table may include:
| Field | Value | | Name | Tom | | Age | 16 | | Address | .... | | Phone Number | .... | | Fav Colour | Red | | Country | UK |
Your scenario 2 may be βLess than 18 years old should not be able to buy a carβ (at least in the UK). Given this scenario, we do not care that Tom has a phone address, only his age. We could write this script as:
Scenario: Under 18s shouldnt be able to buy a car Given there is a customer "Tom" who is under 16 When he tries to buy a car Then I should politely refuse
Instead of storing this Tom parts table in the Feature file, we simply reference the relevant parts. When the Given step starts, automation can search for a βTomβ from our fixtures. The step refers to its age, so that: a) it is understandable to the reader of the Feature file that Tom belongs to, and b) to make sure that the device data is still valid.
The reader of this script will immediately understand what is important for Tom (he is 16), and they do not need to constantly refer between the script and the background. Other scripts may also use Tom, and if they are interested in other aspects of his information (for example, Address), then they can provide relevant information Given there is a customer "Tom" who lives at 10 Downing Street .
Which approach best depends on which of the data you have. If this is a small number of fields across several tables, then we put them in the background, but as soon as it becomes 10 + fields or a large number of tables (presumably, we have many potential clients), I would suggest moving it outside the Feature file and just describe relevant information in each scenario.