Forum Discussion

jshu's avatar
jshu
Occasional Contributor
10 years ago

How to associate the response with the expected result (in data source) please?

I'm testing a simple medical rule, basically this rule requires a patient to visit his/her doctor for the second time AFTER he/she finishes the prescription medicine, for example:   1) Today the ...
  • WirtRo48's avatar
    10 years ago

    Hi Jerry,

     

    you could do this in SoapUI via groovy script. You need 4 steps in your TestCase:

    1. DataSource

    2. Soap-call

    3. Groovy-script for checking the result from the saop-call with your expected result (see below)

    4. DSL to get to the start of the loop again

     

    Your groovy script could look like this:

     

    import com.eviware.soapui.support.XmlHolder;
    def assertionList = [];
    def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );
    def holder = groovyUtils.getXmlHolder(testRunner.testCase.testSteps["<name of the saop-teststep to be executed>"].testRequest.response.getContentAsXml());

     

    // get the result from the soap call
    def soap_result = holder.getNodeValue("<xpath to the tag which holds the result>");

     

    // get the expected result from the datasource
    def ds = testRunner.testCase.testSteps['DataSource']; // name of the datasource
    def dsExpectedResult = ds.getPropertyValue("<name of the column in the datasource which contains the expected result>");

     

    // compare expected with actual result

    if ( dsExpectedResult != soap_result )

     log.info(" Actual and expected result do not match.");

     

     

  • jshu's avatar
    jshu
    10 years ago

    Thanks a lot for the great help!

     

     

    Jerry