I am utilizing SoapUI to check REST webservices and I am caught on a difficulty.
I’ve a json object, referred to as coverages
, which consists of a number of different objects, it seems to be one thing like this (instance with 2 coverages):
"coverages" : [
{
"CovNr" : 123,
"CovDesc" : "My coverage"
},
{
"CovNr" : 456,
"CovDesc" : "Another coverage"
}
]
The factor is, typically there’s one protection, and typically there are a number of. This means I would like the coverages object to be variable, and have both a number of coverages as its physique, relying on # of coverages.
For the reason that variety of coverages is not all the time the identical I am unable to use properties for the CovNr
and CovDesc
attributes. Additionally I am unable to simply all the time add like three and depart two empty if just one is used (cannot have empty attributes).
I attempted to set a coverages property utilizing groovy script, which consisted of your entire physique of the coverages object, however that did not work (I am guessing the editor cannot parse a whole a part of a request from a property).
Instance of what I attempted:
in groovy:
def coverages = "[ { "CovNr" : 123, "CovDesc" : "My coverage" }, { "CovNr" :456, "CovDesc" : "Another coverage" }]"
testRunner.testCase.setPropertyValue("coverages", coverages)
in request physique:
...
"coverages" : "$(#TestCase#coverages)",
...
This did not work.
Is there one other means so as to add a variable variety of coverages to my request physique?