Forum Discussion

vineethwip's avatar
vineethwip
New Contributor
7 years ago
Solved

adding assertions in soap ui to validate xml response tags with database values

hi,

 

I am new to soap ui.can someone help me with adding assertions in soapui to do automated testing of validation of xml response with database values

 

attached is sample request and response

5 Replies

  • JHunt's avatar
    JHunt
    Community Hero

     

    These are all as examples of Script assertions you can add.

     

    new XmlSlurper()
    .parseText (messageExchange.responseContentAsString)
    .counter_party_risk
    .with { assert it.size() == 8 }
    new XmlSlurper()
    .parseText (messageExchange.responseContentAsString)
    .counter_party_risk[1]
    .with { assert it.alert_id == '1767159' }
    new XmlSlurper()
    .parseText (messageExchange.responseContentAsString)
    .counter_party_risk
    .collect { risk -> risk.counter_party_name }
    .with { assert it == ['45XVQ V7I 45XVQ U0CW2 X2T',
                          'N45VU2TT8 40 S2T I2V8 QY2TC2',
                          '2QWQ WQV2U QV SCAS 70ZQ440 V7I',
                          'N W EQ7QA IC78 OA22 40 ZQTP',
                          'N0TI2V2R 2QW72AT 2CA0X2 N5IIV2',
                          'WQZZ GGD 9L9L9L GGD QV AQZ52 W',
                          'TQ750TQV 7AQI5TS I2Y2V0X5T',
                          'QV 0CO0CP 40'] }
    new XmlSlurper()
    .parseText (messageExchange.responseContentAsString)
    .counter_party_risk
    .collect { risk -> risk.total_score }
    .each { assert !( it.toFloat() > 2 ) }