Forum Discussion

ChristianB's avatar
ChristianB
Contributor
12 years ago

How to test if sent input equals to returned output?

Hi everyone,

I have just begun to use soapUI and I wondered whether there is a way to check if what my service returns to me is the same as what I sent in (i.e. if my service just echoes what I sent)?

I thought about setting a property, send it and then use XPath to check whether the reply is the same as what I sent in, but then, I want to look at everything I send in, not just a property/part of the XML request.

Is there an easy way to achieve this?

Kind regards,

Christian

10 Replies

  • Well, I was actually hoping this could be made a generic test: if input equals output, then fail - no matter what the input actually is.
    Is there a chance of doing that?
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    If it's really that simple, how about a Contains assertion with "${request}"?
  • Hi,

    Use XQuery Assertion

    Steps:

    1. Add XQuery Assertion.
    2. Use the below code in the XQuery Expression window
    matches(${Request},${Response})

    3. In the Expected result, type false
  • Hi M McDonald,

    That's it, thank you.
    I'm not yet fully through the documentation, but I suppose a list with available variables will come up eventually? :)

    @saravananramamoorthy: I'm probably missing something, but that throws a Java error for me:
    XQuery Match Assertion failed for path [matches(${Request},${Response})] : RuntimeException:java.lang.reflect.InvocationTargetException
  • M_McDonald's avatar
    M_McDonald
    Super Contributor
    There is probably a list somewhere but if you put the following code into a Groovy script you will get the available properties for the test step. For example, for an HTTP request:

    testRunner.testCase.getTestStepByName('My HTTP Test Request').properties.each { key, value -> log.info key }

    ResponseAsXml
    RawRequest
    Domain
    Username
    Password
    Response
    Request
    Endpoint
  • @saravananramamoorthy: I copied the example you gave me, so if that is all I have to use, then it can't be the brackets, I think.
    @M McDonald: Thank you, very useful. :)
  • Hi saravananramamoorthy,

    I set the test step up again, added the assertion and it's working now. Not sure why it didn't before. Thank you!

    Kind regards,

    Chris