Forum Discussion

MKV's avatar
MKV
Contributor
7 years ago

Compare XML response with DB values

How to compare the XML Response values with DB query output values in Ready API?
  • Radford's avatar
    Radford
    7 years ago

    If you put a Groovy test step after your JDBC request, you could then use property expansions to get your data and perform an assertion, something like:

     

    def soapDataItem = context.expand('${SOAP Request#Response#//Blah[1]/DataItem[1]}')
    def jdbcDataItem = context.expand('${JDBC Request#ResponseAsXml#//Results[1]/ResultSet[1]/Row[1]/ITEM[1]}')
    
    log.info('soapDataItem = ' + soapDataItem)
    log.info('jdbcDataItem = ' + jdbcDataItem)
    
    assert soapDataItem == jdbcDataItem

     

    Note: I've just made up the property expansions as an example, To get your actual data from within the Groovy script editor you can always use the right click menu "Get Data" option. This allows you to construct your property expansion via a visual point and click method.

     

    An alternative to the above Groovy method, might be to put an Assertion Test Step after the JDBC test step, using this instead.