Script Assertion - accessing other Test Steps...
- 8 months ago
Hi schu777
You can leverage the Script Assertion feature in SoapUI.
- By utilizing the testRunner object, you can access data from the "Properties Step" and compare the original LastUpdateDate with the new value retrieved from the current response.
- By parsing the response JSON, extracting the new LastUpdateDate, and asserting that it has changed.
Key considerations include ensuring the correct Properties step name, adjusting the JSON parsing if necessary, and understanding that the assertion will fail if the LastUpdateDate remains unchanged.
// Get the original LastUpdateDate from the Properties step
def originalLastUpdateDate = testRunner.testCase.getTestStepByName("Properties").getPropertyValue("LastUpdateDate")
// Get the new LastUpdateDate from the current response
def responseContent = messageExchange.responseContent
def responseJson = new groovy.json.JsonSlurper().parseText(responseContent)
def newLastUpdateDate = responseJson[0].LastUpdateDate
// Compare the dates
assert originalLastUpdateDate != newLastUpdateDate, "LastUpdateDate has not changed"
log.info "LastUpdateDate successfully updated from ${originalLastUpdateDate} to ${newLastUpdateDate}"
Best Regards