SOAP UI Web Service Testing 102
Author: Alex Siminiuc
Date: June 28, 2011
This second part of the SOAP UI Web Service Testing course will focus on more practical aspects and provide details on the following:
- Create a new project
- Run a web service method request
- Create a test case
- Create a test case assertion
- Run the test suite and get test results
- Other SOAP UI functionalities
Create a new project
Creating a new project is very straightforward. Just open the SOAP UI app, select NEW SOAPUI project from the FILE menu and specify the project name and URL for the web service WSDL file:
SOAP UI will get all details of the web service methods from the WSDL file and load all methods and their requests.
Run a web service method request
In order to run a method request, first select the method in the left pane under the project name. Then, expand the method details by clicking on the + sign displayed before the method name. This will show the default request for the method.
- All method parameters will have sample values that need to be replaced with real values.
- Double-click on the sample request will open the method request in the editor.
- In the left pane of the request editor, the values of the request parameters can be added.
- After that, the request can be executed by clicking on the green triangle.
- The method response will show up shortly in the right pane with all method results.
Create a test case
In the left pane of the project, below the project name, right-click on the method request and select “ADD TEST CASE”.
If the project has any existing test suites, the test case can be added to them. Otherwise, the test case can be added to a new test suite.
Create a test case assertion
Follow the next steps for creating a test assertion for a test case:
- Select the test suite from the project left pane.
- Expand the test suite so that all test cases are visible.
- Expand the test case group from the test suite and then expand the TEST STEPS section.
- Double-click on the test case step.
- The test case step is identical with the method request from above and will re-use all values of the method parameters.
- Double-clicking the test step case will open the test case in the editor.
- Run the test case and get the results.
- Select the assertions tab
Create a new assertion
Add the XPATH code for the assertion so that the results are validated
After the assertion code is added, clicking on the SELECT FROM CURRENT button of the EXPECTED RESULTS section will show if the assertion passes or fails. If it passes, the assertion editor will close and the assertion will be added to the list of assertions for the current test case.
More assertions can be added for the same test case step. The test case can have multiple steps too, each of them with its own assertions.
Run the test suite
After creating all required test cases and their assertions, the test suite can be opened in the editor (right click in the project left pane on the test suite name and select SHOW TEST SUITE EDITOR.
This will open the test suite in the editor with all test cases. Clicking on the green triangle from the top left part of the editor will run all test cases with all their steps and evaluate all assertions for each test case. If at least one assertion fails, then the test case will be flagged as failed.
Please see below the results of running a sample test suite:
Other SOAP UI functionalities
SOAP UI has a lot of other functionalities that I will try to briefly describe here:
There are many types of steps that can be used for a test case; see below all possible types:
- Import test cases from a different project
- Export test cases in XML format
- Move the test case up or down in the test suite
- Disable a test case
- Use a test case for a load test
- Close a test case
It is possible to manage the test coverage and even the requirements for the test cases; however, do not expect complex functionality here:
Using the test cases created earlier, it is easy to run a load test as showed in the next screenshot
Click to Enlarge
Now you should be able to create, manipulate, and execute test cases and load tests with SoapUI.