JDBC script assertion
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2018
02:55 AM
12-06-2018
02:55 AM
JDBC script assertion
Hi,
I have a jdbc request where the result is the following:
<Results>
<ResultSet fetchSize="10">
<Row rowNumber="1">
<STATUS_ID/>
</Row>
<Row rowNumber="2">
<STATUS_ID>20</STATUS_ID>
</Row>
</ResultSet>
</Results>
Can somebody help me to create an assertion where only value 20 and null is accepted all others are failed?
thanks
Solved! Go to Solution.
Labels:
- Labels:
-
Assertions
-
Scripting
4 REPLIES 4
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019
05:57 AM
01-31-2019
05:57 AM
Below script assertion should help you:
/** * Script Assertion for the JDBC Request Test step **/
assert context.response, 'Response is empty or null' def xml = new XmlSlurper().parseText(context.response) def validList = ['20', ''] def statusIds = xml.'**'.findAll {'STATUS_ID' == it.name() }*.text() assert statusIds.every{ it in validList}, 'Invalid values present in the response for Status Ids'
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2019
10:38 PM
02-03-2019
10:38 PM
Hi @martonjurak ,
Did Rao's reply help you?
---------
Tanya Yatskovskaya
SmartBear Community and Education Manager
Tanya Yatskovskaya
SmartBear Community and Education Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2019
12:35 AM
02-04-2019
12:35 AM
Hi Rao,
Thank you for the answer.
Actually I changed my SQL query to get any results only when it is not 20 or null, so in that case I will assert the exists result.
I am sure I will need your assertion in the next weeks so I will try it.
Br
Marton
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2019
05:12 PM
02-04-2019
05:12 PM
No worries. Keep in mind that people are spending time on the questions.
Regards,
Rao.
Regards,
Rao.
