Donkey2017
8 years agoOccasional Contributor
script assertion
Hi, not being a programmer could anyone suggest a way to check if the property "apples" has a number rather than just null for example. So below is the result of running a test. I can easily ask SOAP to check if there is an item called "apples" but I have no idea how to ask if "apples" equals a numerical value- any value not just 111.
{
"CONTENT":
{ "apples": 111,
},
.......in my own language.... I have a test in SOAP- one element of that test = "apples". I want to add a SCRIPT Assertion that checks that the test has created a Value for "apples" and not just a blank or "0".
thanks in advance
.....almost total non-programmer
//Below Script Assertion should do the job
def json = new groovy.json.JsonSlurper().parseText(context.response) //check id is number assert json.CONTENT.id instanceof Integer, 'id is not integer type' assert 0 < json.CONTENT.id, 'id is not a positive number'