Forum Discussion

soapuiuser's avatar
16 years ago

SOAPUI beginner question

I have the following question,

to assert that value returned by an element in the web service response is an integer or float or double with some XX.YY precision. is it possible to do this in SOAPUI? if yes, is it done with groovy script, if yes, could someone please share some code for reference.

Thanks in advance.

1 Reply

  • Hello,

    One way to do this would be using XPaths rounding function. For instance, say I have a response containing the value "3.14159265358979323846064338327950" and I need to assert that it would round to 3.14 (with a 2 decimal precision). Since XPath only has a round function that rounds to the nearest integer (at least I didn't find any other function now) I would simply start by multiplying the value with 100 and then rounding it. Once rounded, divide by 100 again. The value I then compare to is 3.14 So the XPath for this might look like:


    round(//path/to/value/number() * 100) div 100


    Hope this helps you! The value you test against can be either static or a Property Expansion.

    Regards,
    Dain
    eviware.com