01 March 2010 - 3.5 user guide eclipse intellij netbeans maven download nightly forum bugs blog sf.net eviware


Eviware Logo

soapUI Conditional Gotos

Conditional Goto steps evaluate an arbitrary number of XPath conditions on the previous requests response message and transfer TestCase execution to the TestStep associated with the first condition that evaluates to true. This allows for conditional TestCase execution paths, where the result of some request controls how to move on in the TestCase. If no condition matches the current response, TestCase execution continues after the Goto Step as normal.

Sample scenarios could be:

  • Branching depending on results returned by a request
  • Restarting after a "longer" delay (minutes) for surveillance testing
  • Repeatedly waiting and checking for a status value before moving on (for example on a batch-process)

Conditions use the same Saxon XPath engine as described for the XPath Assertion, remember that a condition must evaluate to a Boolean value to be valid (see Goto examples below)

The soapUI Conditional Goto Editor

The ConditionalGoto Editor is opened by double clicking a ConditionalGoto test step either in the navigator or in the TestCase Editors' test step list.

The editor contains a list of configured conditions to the left, selecting an existing condition in the list will display that condition's expression and a target TestStep ComboBox to the right. The Test Condition button will evaluate the current condition against the current response and display the result (a response message must be available for the preceding TestRequest).

soapUI Pro adds an XPath Selector button to the right of the Test Condition button for easily selecting the XPath that should be used for evaluation.

soapUI Conditional Goto Editor

The following actions are available from the bottom toolbar

  • Add : prompts to add a new condition to the list
  • Copy : prompts to create a copy of the selected condition
  • Delete : prompts to delete the selected condition
  • Rename : prompts to rename the selected condition
  • Run : runs the conditions and displays which condition that matched the current response (a response message must be available for the preceding TestRequest)
  • Declare : declares namespaces in the selected conditions expression field. Namespaces are extracted from the preceding TestRequests current response message (if available).
  • Online Help - Displays this page in an external browser

Goto Condition Examples

Conditions must evaluate to a Boolean value, for example the following expression checks that there are hits in the search result returned from the Amazon web service:

declare namespace SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/';
declare namespace ns1='http://webservices.amazon.com/AWSECommerceService/2005-10-05';
declare namespace SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/';
count(//ns1:Item)>0

A generic condition that checks for a soap body would be:

declare namespace SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/';
count(//SOAP-ENV:Body)=1

and the corresponding check for a soap fault would be:

declare namespace SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/';
count(//SOAP-ENV:Fault)=1


Next: Web Service Test Scripts - Groovy Script Steps