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.
- Using the context menu, add a Test Suite (“Arithmetics Test 1″).
- Using the context menu, add Test Case (“Add”).
- Define properties you want to use during the test. First, enable properties in the tree by clicking the properties icon on the top left.

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

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

- 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} - 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”.

- I like to validate the result with an XPath Query 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. - We are ready to run our small test: Open the test and click the run button.

If all icons are green, we’re set!
Stay tuned for a more complex example…
Anke
