Forum Discussion
14 Replies
- IgorG
Staff
You seem to try to do several things in one assertion.
Here is how you can try and assert the response::
- Use Message Content assertion to verify the contents of the response. With it you can configure what information you expect in specific response field.
- Use Script assertion to verify response lenght. Depending on your response, there are multiple ways to do this. The simplest one is checking response lenght:
assert messageExchange.response.contentLength < 500
This is obviously very basic, a script should be custom for what you expect in your response. You can, for example, get a response as XML, count the number of specific nodes in it and fail the assertion if there are too many.
- testhrishiFrequent Contributor
Thank you for the input, the < length may work to cover for more than expected scenario. But it may not cover the less than expected part, right. Also some of the fields coming back in the response are new every time, hence its gets tricky to assert on specific ones
- IgorG
Staff
You can use this code to check both minimum and maximum length:
assert ((messageExchange.response.contentLength > 10) && (messageExchange.response.contentLength < 500))
Of course, this will only work if short, normal and long messages are different enough.
- RadfordSuper Contributor
Are you asserting the contains on the entire JDBC response or individual fields?
- testhrishiFrequent Contributor
In this case entire JDBC response
- RadfordSuper Contributor
I've always run into issues when I used to attempt to match the entire response. Can you just assert the individual fields in the returned JDBC XML response?