Forum Discussion

PrakashKannan's avatar
PrakashKannan
Contributor
7 years ago

Fail 'SOAP request test step' from event handler

I want to check one condition in each test step response and If response has <my condition> then I have to fail the test step.

 

I created a event handler in a project level

'TestRunListener.afterStep' event handler with following code

 

import com.eviware.soapui.support.XmlHolder

def holder = new XmlHolder( messageExchange.responseContentAsXml )
def response=holder.getDomNode(myXpath)
if(mycondition)
//fail  test step

testRunner.fail("Fail")
else
//pass test step

 

Two Question:

 

1.This is not failing the test step

2.If I want to fail only the SOAP test request how can I specify in the target of the event handler ?

 

 

3 Replies

  • I haven't used that afterStep event handler. Why not try adding a assertion  step after the test step - see if it works. If it does not, maybe something in the afterStep groovy script  is not doing what you intended.

    • PrakashKannan's avatar
      PrakashKannan
      Contributor

      Thanks for the suggestion. I tried to assert but it does not work.

      • Bill_In_Irvine's avatar
        Bill_In_Irvine
        Contributor

        Okay. I don't work much with XML. Perhaps someone like Rao will see your post and offer help.

         

        Good luck!