madhu_112
4 years agoOccasional Contributor
Update the previously available balance only when there is a change in available balnce
Hai, can someone help me with this problem..
I've availbalance = 123 and prevavailbalance = 121(this should only update when there is a change in availbalance, in this case 121 was previously available balnce) - both are coming from json response
now my question is i'm writing a script to check whether the prevavailbalance is correct or not? i'm stuck here how to set this thing up.
madhu_112 It should be easy to deal with it with groovy script.
Since it retrieve available balance from json response, you may need to save it in properties (i.e test suite properties) and next time get new balance and compare them.
For example:
test suite properties: availbalance = 123
in REST step:
// add script in response import groovy.json.JsonSlurper def response = messageExchange.response.contentAsString def json = new JsonSlurper().parseText(response) // assume that you save availbalance in test suite level def availbalance = context.expand ('${#TestSuite#availbalance}').toInteger() // please replace with your json path def newbalance= json.availableBalance if (availbalance != newbalance) { messageExchange.modelItem.testStep.testCase.testSuite.setPropertyValue("availbalance ", newbalance.toString()) }
Thanks,
/Aaron