My team is testing a REST API using Cucumber. The steps make calls to the API while the scenarios have things like "Given I make call to XXX with JSON YYY".
Would it be very bad practice to set JSON variables in the background of feature files, and then manipulate/use them for the different scenarios? Many of our tests are using the same JSON objects with only 1-3 edited elements. I would like to do something like this for a scenario:
Given I update J element to K value in JSON YYY As <NewJsonVariable>
...
This seems like bad practice since Cucumber is itself a debatable tool for REST API testing, but now I'm wanting to put variables into the mix for the feature. However, I have some features that are 5-10k lines (broken into multiple files) and I estimate I could get this down to 500-1k lines and make it MUCH more readable. The only thing is that the test writer/reader now has to keep JSON variables in their head, but the tests are short enough that there would only be 2 or 3 variables at once.