Forum Discussion
SmartBear_Suppo
Alumni
14 years agoHi,
The script assertion you have can never be successful, it will either be false or thrown an exception. There are two possible outcomes:
responseContent IS NOT null, causing the assertion to fail.
responseContent IS null, causing a NullPointerException when it is being dereferenced to make the equality check, which will prevent the assertion from even being made.
I don't believe that soapUI will ever return a null value for responseContent, so the exception case may never occur (though I'm not entirely sure about that). What I think you mean to check against is an empty response, I.E. an empty String OR a null value. Doing this in Groovy is quite easy, as Groovy will automatically convert such a value into false when used as a boolean expression. Try changing the assertion to this:
Regards,
Dain
SmartBear Software
The script assertion you have can never be successful, it will either be false or thrown an exception. There are two possible outcomes:
responseContent IS NOT null, causing the assertion to fail.
responseContent IS null, causing a NullPointerException when it is being dereferenced to make the equality check, which will prevent the assertion from even being made.
I don't believe that soapUI will ever return a null value for responseContent, so the exception case may never occur (though I'm not entirely sure about that). What I think you mean to check against is an empty response, I.E. an empty String OR a null value. Doing this in Groovy is quite easy, as Groovy will automatically convert such a value into false when used as a boolean expression. Try changing the assertion to this:
assert ! messageExchange.responseContent
Regards,
Dain
SmartBear Software