How to Setup Testcases and Assertions in SoapUI

How to Setup Testcases and Assertions in SoapUI

SoapUI is one of the commonly used tools for testing web services. In this article, we will see how to setup a simple test case and add assertions in SoapUI.

Creating Project

  • Open SoapUI and right click on the projects tab on the left sidebar and select New SOAP Project.
  • Provide the WSDL url in the Initial WSDL text box. If you have a local WSDL file, just click Browse and select the file. For this demo, I have used a public temperature conversion web service from WebserviceX.

Create Project

  • SoapUI automatically loads the WSDL and generates the templates for all available services under the WSDL. As shown below, it has two services – ConvertTemperatureSoap and ConvertTemperatureSoap12. We will use the latter.

Create Test Case

  • Right click on Request 1 under ConvertTemp service and select Add to TestCase. This will ask you to provide the names of Test Suite, Test Case and Test Steps.

Create Test Case

  • The Test Suite will be created as shown below.
  • Double click on ConvertTemp – Request to open up the template. Populate the template with the values and press the Run button (top left end) to execute the service.
  • We will get the response as shown below.Response

Adding Assertions in SoapUI

  • Now that we have the response, let’s add an assertion to validate the response.
  • Click on the assertions tab on the bottom left to bring up the assertions tab. Click on the plus sign to add a new assertion.
  • Since our response in in XML, lets add an XPath Match assertion from Property Content > XPath Match
SEE ALSO:   Test Responsive Design using Galen Framework

XPath Match

  • We have to provide the namespace in the Xpath Expression. Click on the Declare button to automatically declare the namespaces

XPath Assertion

  • Now give the XPath for the tag you need to verify. Now click on the ‘Select from current’ button. This will validate the XPath Expression and obtain the value from the current request. This is a helpful way to check whether the XPath we provide is valid or not.


  • Now execute the request again and see that both the assertions are passed.

Assertion in SoapUI

  • You can also execute the test step from the Test Cases tab.


Negative Case for Assertion

  • Now, let’s add a negative test case. I have duplicated the test case and have changed the value of FromUnit to an invalid one.


  • Open up the XPath assertion and modify the XPath Expression to handle the new negative response as shown below.

Negative Assertion

  • Now run both the test steps from the Test Cases tab. As you can see below, both positive and negative cases have passed.



Hope you found this simple tutorial useful. We will be covering more complicates functionalities of SoapUI in the next post.

Like us on Facebook or follow us on Twitter to get updates on coming posts or Subscribe to our Newsletter.

Further Reading:

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *