In this guide you'll learn how to create a test from a request in your WSDL, add an assertion to the test and to run the test. We will be using SoapUI Pro, so it's recommended that you download SoapUI Pro Trial before starting.
Why use SoapUI Pro for Functional Testing?
While the Open Source version can be seen as the Swiss-Army knife for testing, SoapUI Pro is the tool with the sharpest edge. Applied to the Functional Testing area, SoapUI Pro focus on enhancing efficiency and usability. With Point and Click Testing, you can drag and drop instead of manually writing the code. The Form Editor creates a form from your request, further eliminating the need for you to spend time on repetitive coding. These functions make, in combination with The Outline Editor who simplifies and exposes the XML structure, your testing more fun and less time consuming. If creativity, flow and speed are important to you as a tester, SoapUI Pro is too.
Watch the video tutorial:
The step-by-step guide:
1. Create a test from a request in your WSDL
1. Click on the plus sign next to the web service in the navigator to expand.
2. Double click on the request.
In SoapUI Pro, the request editor comes up to the right. SoapUI Pro has an Outline Editor that simplifies the hierarchical structure of the XML, both in requests and responses, and at the same time is customizable.
Learn more about The Form Editor and The Outline Editor.
If you are using SoapUI Open Source, you have to enter your data manually in the code editor as shown below. To benefit fully from this tutorial you should use the Pro version. You can download the Pro Trial version for free here, giving you 2 weeks access.
3. In the request editor, select Add This Request to TestCase. SoapUI Pro takes the definition of the request and makes a form for you to enter information in. This may be especially useful when doing manual testing or if you want non-technical staff to enter a request.
4. Adding a request to a TestCase will open the Create TestSuite dialog box. Enter a name for your TestSuite and click OK.
5. After clicking OK, you will be asked to create a TestCase. In the Create TestCase dialog, enter a name for your TestCase and click OK.
6. Next, the dialog box Add Request to TestCase will appear. Click OK.
7. SoapUI Pro will now generate a TestSuite and TestCase for you while the request will be added as a TestRequest. Below is a copy of the request that appears in the interface. A TestCase editor will also open with your new TestRequest.
The next step is to validate the response in your test by adding an Assertion.
2. Add an Assertion to the test
Now that we've created and run our first test, we are going to add a validation of the response. In SoapUI, this is called adding an assertion. SoapUI Pro contains several functions that enhances automation for those who spends their days (and nights) testing and are in need of extensive assertions.
Examples of assertions that is possible in SoapUI are:
- Schema Compliance
- Simple Contains
- Simple Not Contains
- SOAP Fault
- Not SOAP Fault
- SOAP Response
- Response SLA
- XPath Match
- XQuery Match
- Script Assertion
- WS-Security Status
- WS-Addressing Response Assertion
- WS-Addressing Request Assertion
1. Close all windows you have open in soupUI before starting. Double Click on your Test Request as shown below. This will open the request editor.
2. In the request editor, Click the Add an Assertion to Test Request button.
3. Select Response SLA from the drop down in the Select Assertion dialog box.
4. In the Configure Response SLA Assertion dialog box, write 500 and click OK. This will validate that the response of the SLA is under 500(This is measured in milliseconds, 500 should be half of a second).
5. Now that you've added the assertion, you are going to run the request to validate the response. If all assertions are successful, the SOAP icon should turn green in three places as shown below.
Tip! You can see how many assertions you have in a test by looking at the assertions tab. The number of assertions is written on the tab "Assertions (2)"
6. You can also validate the response by adding an XPath Match assertion.
7. In SoapUI Pro you can open the Select XPath dialog, which let's you select nodes to assert using point-and-click. As a result SoapUI creates the matching XPath expression that refers to the selected node.
8. SoapUI automatically populates the expected result to match what's in the response. But of course, you can change this to what's relevant for you.
Learn more about Point and Click Testing.
9. Now let's try and enter the ianacode SE (for Sweden) as a request, and execute the test.
10. Oh no! The test failed! SoapUI gives us a red icon in three different places, and the Assertions-tab expands telling us that our XPath Assertion failed. This is because we said that the allregionslist should contain the US states, and we asked for the Swedish regions.
11. Change back the ianacode to US and try executing the test again. You will now see that all assertion are set to "VALID". This is because the we now get the list of US States in the response, which is what the XPath Assertion is looking for.
Now that you know what an assertion is and how you add one to the test, it is time for the final exam of this guide - to run the actual test.
3. Run a test
There are several different places in SoapUI where you can run the test. You can do it on a TestStep level, which is what we have done in this guide.
You can also try running the TestCase from the TestCase Editor…
…or from the TestSuite Editor.
Try SoapUI Pro for free!
By going Pro you get everything thats in SoapUI plus a bunch of productivity and time-saving enhancements. Download our 2-week free trial and try them out for yourself!