Search code examples
web-serviceswsdlsoapui

How to have a SoapUI test successfull if SOAFault has a particular message?


I have a SoapUI test that performs a WSDL call.

This WSDL call is considered a success if either

  • response is a valid SOAPResponse
  • response is a SOAPFault with a specific faultstring

How can I write a SoapUI test that will be successfull in both cases (and obviously only those cases) ?

EDIT my test case already has 3 assertions defined :

  • SOAP Response
  • Schema compliance
  • Not SOAP FAULT

I would like to have something like

  • SOAP Response
    • Schema compliance
    • Not SOAP FAULT
  • SOAP Fault
    • XPath Match

Solution

  • SoapUI will not be able to do what you want out of the box. All assertions you specify have (equivalent of) boolean AND: they all have to pass, to pass the step.

    I can see two options to solve your dilemma.

    1. Restructure your test case(s), so that you can check the fault separate from the non-fault.
    2. You will have to use a Groovy script assertion, do handle your logic.

    Possibly something like:

    def status = messageExchange.responseHeaders["#status#"][0]
    if(status.contains("500")) {
        log.info "Fault"
        def faultStr = context.expand( '${#Response#//*:faultstring}' )
        assert faultStr.contains("something special")
    } else {
        log.info "Non Fault"
    }
    

    Your other two assertions, SOAP response and Schema compliance, should apply regardless of fault or not.