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.
Web Services in the navigator

2. Double click on the request.
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.
SoapUI Pro
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.
Open source view of SoapUI


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.
Add This Request to TestCase

4. Adding a request to a TestCase will open the Create TestSuite dialog box. Enter a name for your TestSuite and click OK.
Create TestSuite

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.
Create TestCase

6. Next, the dialog box Add Request to TestCase will appear. Click OK.
Add Request to TestCase

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.
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.
Request

2. In the request editor, Click the Add an Assertion to Test Request button.
Test Request

3. Select Response SLA from the drop down in the Select Assertion dialog box.
Add an assertion to test request

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.
Select assertion

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.
How Many Assertions

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.
Select assertion - XPath Match

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.
XPath Match - Select XPath Pro
Select XPath - Chosen 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.
XPath Match Expected Results
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.
Search for SE

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.
Xpath Assertion Fails

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.
Xpath Assertion Valid

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…
TestCase Editor

…or from the TestSuite Editor.





TestSuite Editor 

 Reference: http://www.soapui.org








Post a Comment

 
Top
1 2 3 4 5 6 7 8 9