Hi,
Low priority Query - I've found a way around this by adding in a separate groovy step instead - I was just wondering the reason for the behaviour
Original script is as below - and it asserts that the 'entityLogicalName' attribute value is <> 'appointment' - courtesy of rao
**
* Below is the script assertion for the REST Request Test step
**/
def json = new groovy.json.JsonSlurper().parseText(context.response)
def logicalNames = json.sessiondata.'appointment.nhs_slottype'.entityLogicalName
def checkFor = 'appointment'
//Negative check - value should not have appointment "!=",
//Positive check - use "==" to match value with appointment
assert logicalNames.every {it != checkFor}, "Not expecting value ${checkFor} for entityLogicalName, but found"
so - I decided due to project requirements that I needed to assert that a second attribute value should NOT contain a certain value - I duplicated the def logicalNames, def checkFor and the assertlogicalNames lines for an extra attribute check as below:
def json = new groovy.json.JsonSlurper().parseText(context.response)
def dataDescriptionvalue = json.data.Description
def checkForDescriptionval = 'A list of certificates'
def dataTitlevalue = json.data.Title
def checkForTitleval = 'Certificates'
//Negative check - value should not have certificates "!=",
//Positive check - use "==" to match value with certificates
assert dataDescriptionvalue.every {it != checkForDescriptionval}, "Not expecting ${checkForDescriptionval} value for dataDescriptionvalue, but ${checkForDescriptionval} value was found"
assert dataTitlevalue.every {it != checkForTitleval}, "Not expecting ${checkForTitleval} value for dataTitlevalue, but ${checkForTitleval} value was found"
HOWEVER - the second assertion never fires - essentially cos the step fails I suppose.
Can anyone confirm that this is the case (I removed the 'abort test if error occurs' checkbox on the test case) - but the second assertion didn't appear to fire
I did get around this by adding splitting the code to check the 2nd attribute and the associated assertion into a second groovy step - so my test case hierarchy is as follows:
REST Step
GroovyStep - checks the 'Description' attribute and asserts it doesn't contain 'A list of certificates'
GroovyStep - checks the 'Title' attribute and asserts it doesn't contain 'Certificates'
I am just wondering if there's a reason why you can't have another assertion in the same groovy test step? I understand it complicates things in case you get one assertion passing and one failing, but I would've thought it would report both the step failing anyway - just like it should in a manual test if you ever do include 2 assertions/verifications in the same step.....
Cheers!
richie