0
In Part I and Part II we discussed about web services testing types. In this blog I will explain the SOAPUI tool to test web services.
What is SOAPUI
SOAPUI is a free and open source cross-platform Functional Testing solution. With an easy-to-use graphical interface, and enterprise-class features, SOAPUI allows you to easily and rapidly create and execute automated functional, regression, compliance, and load tests

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.
  1. 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.
  2. Adding a request to a TestCase will open the Create TestSuite dialog box. Enter a name for your TestSuite and click OK.
  3. 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.
  4. Next, the dialog box Add Request to TestCase will appear. Click OK.
  5. 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.
  1. Select Response SLA from the drop down in the Select Assertion dialog box.
  2. 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.
  3. 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)”
  1. You can also validate the response by adding an XPath Match assertion.
  2. 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.
  3. 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.
  1. Now let’s try and enter the ianacode SE (for Sweden) as a request, and execute the test.
  2. 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.
  3. 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.

Reference: http://www.soapui.org

Post a Comment

 
Top
1 2 3 4 5 6 7 8 9