26 September 2007 - 1.7.6 | home user-guide eclipse jbossws intellij netbeans maven 1.X/2.X PDF files forums bugs sourceforge

Home
Getting Started
User Guide

- Overview
  - Tabbed Desktop
  - License Management
  - Preferences
  - XPath Selection
  - Script Library
- Workspaces
- Projects
- Interfaces
  - Interface Viewer
- Operations
- Working with Requests
  - Form Editor
  - Overview View
  - Outline Editor
  - Message Inspectors
  - Attachments/Inline Files
- Functional Testing
  - Getting Started
  - TestSuites
  - TestCases
    - Test Requests
      - Assertions
      - Editor Wizards
    - Property Transfers
    - Conditional Gotos
    - Groovy Scripts
      - Examples
      - GroovyUtils
    - Properties Step
    - Delay Step
    - Mock Response
    - DataSource
    - DataSource Loop
  - Property Expansion
- Load Testing
  - Getting Started
  - Limit & Strategies
  - Execution
  - Assertions
  - Diagrams
  - JMeter comparison
- Mocking
  - Getting Started
  - Mock Services
  - Mock Operations
  - Mock Responses
- Usage Scenarios
  - Data-Driven Testing
  - Template-Driven Testing
  - Interactive Testing
  - Surveillance Testing
- Tool Integrations
  - Code Generation
  - WSDL Generation
  - WS-I Tools
  - Apache Tcp-Mon
- CommandLine Tools
  - TestCaseRunner
  - LoadTestRunner
  - MockServiceRunner
  - ToolRunner
- Keyboard shortcuts

IDE/Tool Plugins
Search soapUI site
Project Documentation

- About soapUI
- Project Info
- Project Reports

## 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 examples below)

### The 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.

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

### 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: Groovy Script Steps