Forum Discussion

KRR's avatar
KRR
New Contributor
7 years ago
Solved

Assert not equals a specific value

I have a web service that I am creating a test suite for in Soap UI Pro (Ready API 2.0). I need to add an assertion that a particular field does NOT return the value 1.0 but I can't figure out how to do this.

 

Here is what my raw response structure looks like:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns1:myWebService>
         <return>
            <factor>1.00000605897785</factor>
            <level>A</level>
            <amount>281431.98</amount>
         </return>
      </ns1:myWebService>
   </soap:Body>
</soap:Envelope>

I need to verify that the value returned in the "factor" is not 1.0. It can be like the value here where there are extended decimal places; just as long as it is not exactly 1.0 it is valid. 

 

There isn't a convenient "Not Equals" assertion, nor would a "not contains" work here, so I assume that I would have to do this with a script, but I am very new when it comes to scripts in general and Groovy in particular.

  • So if you use an XPATH assertion, you'd end up with an xpath statement that ends up like:

     

    //ns1:myWebServce/return/factor

     

    in the top part of the assertion and 

     

    1.00000605897785

     

    in the bottom pane, saying that this is the expected value.

     

    You can change your XPATH statement to  

     

    //ns1:myWebServce/return/factor = 1.0

    and have your expected value be

     

    false

5 Replies

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    So if you use an XPATH assertion, you'd end up with an xpath statement that ends up like:

     

    //ns1:myWebServce/return/factor

     

    in the top part of the assertion and 

     

    1.00000605897785

     

    in the bottom pane, saying that this is the expected value.

     

    You can change your XPATH statement to  

     

    //ns1:myWebServce/return/factor = 1.0

    and have your expected value be

     

    false
    • KRR's avatar
      KRR
      New Contributor

      That worked perfectly, thanks. I didn't know an XPATH match could be used that way.

      • KRR's avatar
        KRR
        New Contributor

        I'l look into that to understand Groovy better in the future!