I wrote a test in Postman which works when a choice is made from the underlying table. The chosen data is then fetched and written to the console log for the next request.
For example as shown in the console log: “value of standardFunction:Greece”
I also successfully wrote a test (almost the same one) for when for a certain field no choice was made from the underlying table. This will be null in the console log, which is fine.
For example as shown in the console log: “value of standardFunction:null”
But I need to choose between those tests and upfront I don’t always know if there will be data chosen from the underlying table or not.
This works in case there is data to be fetched:
bodydata = JSON.parse (responseBody) // to parse json response
valuestandardFunction = bodydata._embedded[0].standardFunction.value
console.log (“value of standardFunction:” + valuestandardFunction) pm.environment.set(“standaardfunctie”, valuestandardFunction);
This works when there is no data to be fetched:
bodydata = JSON.parse (responseBody) // to parse json response
valuestandardFunction = bodydata._embedded[0].standardFunction
console.log (“value of standardFunction:” + valuestandardFunction) pm.environment.set(“standaardfunctie”, valuestandardFunction);
The only difference between the two is the .value in the second row.
My question is; what do I need to change to my test so that it sees the difference between there being data and null? So that I can use this test in both scenarios.
I really hope someone can help, thanks in advance!