abderrahim_05
abderrahim_05

Reputation: 465

How to use assertions in soapUI to match with external property

I have a test case containing the test steps below :

In the LoadTestDataStep i load some data from a JDBC database that i will need later in the 'SoapRequestStep'

The GetPropertyStep allow me to retrieve data from LoadTestDataStep result and put them SoapRequestStep request.

Now in the SoapRequestStep i want to assert that an evaluation of some xpath matches some data i retrieve in the LoadTestDataStep

I hope i made myself understandable.

this the JDBC result :

<Results>
    <ResultSet fetchSize="10">
        <Row rowNumber="1">
            <DRV_DVR_ID>46259976</DRV_DVR_ID>
            <CUST_DPT>00025888</CUST_DPT>
        </Row>
    </ResultSet>
</Results>

And this is the SOAP Result (simplified) :

<chargeCard chargeSequence="1353" businessAccountId="1520444" ownershipType="N" meanOfPaymentCode="EPPV" cashOrChargeFlag="CH" custdept="982-1602"/>

I want to assert that the CUST_DPT from JDBC = the custdept attribute from the soap response.

The problem is that in the SoapStep i cant assert against something external to this soap step

Upvotes: 1

Views: 450

Answers (1)

Chris Adams
Chris Adams

Reputation: 1454

"The problem is that in the SoapStep i cant assert against something external to this soap step" Yes, you can assert against something from another step.

In your step's '(SOAP) SoapRequestStep' script assertion, you can pull in the response of the JDBC step by doing something along the lines of....

def jdbsResponseAsXml = context.expand( '${(JDBC) LoadTestDataStep#ResponseAsXml#//Results[1]}' )

def slurper = new groovy.json.JsonSlurper()
def jdbcJson = slurper.parseText(jdbsResponseAsXml );

With the above steps, you'll have the jdbc result in JSON form in the '(SOAP) SoapRequestStep' script assertion.

You'll then need to find the node of interest and compare.

Additionally, and this is my own preference, I tend not use to script assertions in this way. Instead, after the two steps of interest, I would create a new Groovy script test step and in there I would pull the data from the steps of interest and assert in there.

Upvotes: 1

Related Questions