Prepare test case in SoapUI using SQL script and custom properties

When prepare test case in SOAPUI, you might need to select a bunch of data from database to create your test cases. This can be done by using JDBC request as test steps in SoapUI.

The next step is to save script result (data set) in properties that can be retrieved by other test steps for example SOAP request. But how to extract values from result xml and save as string list? Assume we need to read MEMBER field from above sample.

Here is the answer. We can add a new property transfer step in SoapUI. Use XQuery script to read MEMBER field from xml.

XQuery script:

for $id in //Results[1]/ResultSet[1]/Row/MEMBER
return string($id)

The output result: “12345678 23456789” will be saved into properties where you defined as target.

Almost there! As SQL script returns a list of member then we will read each individual member from list and populate them into SOAP request.image003

Groovy script: ${=testSuite.getPropertyValue(“abc”).tokenize(‘ ‘)[0]} utilize tokenize function that returns the first member in the list.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s