QAT Insights

Highlighting recent QAT solution releases, insights, service and industry information, upcoming events, case studies, and press releases.

Web Service Testing with soapUI Part 2 – A Simple Unit Test

September30

In my previous post I’ve shown how soapUI can quickly create and run SOAP requests for you. Now I want to create a simple test case to show a few features that can be used for unit and load testing.

  1. Using the context menu, add a Test Suite (“Arithmetics Test 1″).
  2. Using the context menu, add Test Case (“Add”).
  3. Define properties you want to use during the test. First, enable properties in the tree by clicking the properties icon on the top left.soapUI Enable Properties View
  4. By clicking/right-clicking into the properties sections, you can now add properties and set their values. In my case, I added all properties at the test suite level to make them accessible to all test cases in that test suite. They also could be added to the Test Case itself.  soapUI Set Properties
  5. Add a Test Step to the Test Case by right-clicking on the Test Case and selecting “Add Step–>Test Request”. I named my step “Basic Addition”. I selected the “add” method from “ArithmeticsSoapBinding”. soapUI Select Test Step Request
  6. Open the new Test and add the test values. In this example, I’m referencing the test suite parameters – access Test Suite properties like this:

    ${#Testsuite#BasicNum1}

    The request can be run now for testing purposes.soapUI Set Test Request Values

  7. For the test to be a true test, we need to validate the result. The easiest way is to add assertions that are automatically run against the SOAP result. On the left bottom corner of the request, select “Assertions”.
    soapUI Add Assertion
  8. I like to validate the result with an XPath Query assertion:soapUI XPath Assertion
    A few tips for writing XPath assertions: The “Declare” button above the XPath Expression text box automatically adds all namespaces that it knows about (saves a lot of typing!). If you have successfully run the request at least once, you can debug/test your expression with the “Test” and “Get from current result” buttons above the “Expected Results” text box.
  9. We are ready to run our small test: Open the test and click the run button.soapUI Run Test Case

If all icons are green, we’re set!

Stay tuned for a more complex example…

Anke

posted under Web Services

Comments are closed.