soapUI: Creating a Test Suite and Test Step

In my last post I provided a brief overview of soapUI, a popular tool for testing web services. In this post I'll go into a little more detail and cover some basic soapUI procedures and concepts.

As I mentioned in my previous post, soapUI can build a basic test suite from a WSDL.  For this mini-tutorial, I'll be using a web service based on the periodic table of elements that allows users to retrieve symbols, atomic weights, etc.  In soapUI, select File - New soapUI Project and enter a Project Name and the following Initial WSDL/WADL:

http://www.webservicex.net/periodictable.asmx?WSDL

Check the box to generate a test suite and click OK. You'll see soapUI automatically load definitions for our web service, after which it prompts the user for test suite creation options, which include selecting which operations you'd like to include and how you'd like them grouped in test cases. Just accept the defaults here (you may be prompted twice-- soapUI is building test suites for SOAP 1.1 and 1.2 bindings; you can use either for the following examples).

On the left-hand side of the window you'll see the workspace navigator; after a successful import you'll see interfaces and generated test suites for the web service.


soapUI Workspace Navigator

Using the default options, each operation will have its own test case consisting of a single SOAP request test step.  Let's actually build a test request and send it to the web service.  Drill down into the test suite for the periodic table web service and double-click on the GetElementSymbol test step to launch the test step editor.  The GetElementSymbol operation takes a single input parameter, an element name, and returns its symbol in the periodic table.  Modify the test request in the left pane of the editor so the ElementName parameter is "Silver" (replace the "?" between the ElementName tags with "Silver").  Then click the Submit Request button at the top of the window-- the leftmost button that looks like a Play button.  The test request is sent to the web service and you should see the response in the right pane.


SOAP Request Test Step

Now that we have a working SOAP request test step we'll want to create some assertions to validate our response data.  Click the Assertions button at the bottom of the soapUI window to expand the Assertions panel (displayed across the lower part of the window).  Click the Add Assertions button (leftmost button at the top of the Assertions panel) to launch the Add Assertion dialog-- here you can look through some of the different Assertion types that are available.


Add Assertion dialog

From the SLA section, select the Response SLA assertion type and click Add.  This assertion type confirms that the given test request receives a response within a specified period of time; you'll be prompted to specify the acceptable response time (in milliseconds) before the assertion is added.  Enter 10000 (10 seconds) here.

Add a Not SOAP Fault assertion (from the Compliance, Status and Standards section) to verify that the test response is not a SOAP Fault, and finally, add a Contains assertion from the Property Content section to validate response data.  Since this particular SOAP request is pretty straightforward with only one piece of data returned in the response (the element's symbol), the Contains assertion should be adequate.  You'll be prompted to enter a string to look for in your test response; enter text matching the response's Symbol element: "Ag" (the quotation marks should not be included).

For any subsequent runs of your test step, your SOAP response will be validated automatically against the added assertions with the pass/fail status of each indicated by "green light"/"red light" icons in the Assertions panel.


Assertions panel with pass/fail statuses indicated

The SOAP Request test step is just one test step type-- in the next post, we'll look at some of the others.

3 comments:

  1. Nice post to learn assertions. I like it very much as it is in very detailed way for begineers.i look forward to see some more tutorials.

    ReplyDelete
  2. I get this error when running
    System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.IO.IOException: There is not enough space on the disk.

    ReplyDelete
    Replies
    1. There's been an ongoing issue with webservicex.net that results in that error. You can try alternative web service WSDLs. Two sites I've used to find free web services are xmethods.net and programmableweb.com. One service that seems to be working now is http://www.holidaywebservice.com/Holidays/HolidayService.asmx?WSDL ...

      Delete

Please be respectful of others (myself included!) when posting comments. Unfortunately, I may not be able to address (or even read) all comments immediately, and I reserve the right to remove comments periodically to keep clutter to a minimum ("clean" posts that aren't disrespectful or off-topic should stay on the site for at least 30 days to give others a chance to read them). If you're looking for a solution to a particular issue, you're free to post your question here, but you may have better luck posting your question on the main forum belonging to your tool's home site (links to these are available on the navigation bar on the right).