REST Functional Testing

When creating a functional TestCase in SoapUI, a common scenario is that you want to call some REST Resource and validate its response to check that the correct result is returned. This can be easily achieved:

  1. Add a REST Request TestStep to a new or existing TestCase
  2. Add Assertions to the TestStep that validate the response message

Adding the Request TestStep can be done in several ways:

  1. By pressing the “Add to TestCase” button on the top left of the message editor or the “Add to TestCase” action from the Request Popup Menu. This will prompt for which TestSuite/TestCase to add to (or create new ones) and then open the following dialog:
    add-rest-request-to-testcase
  2. By pressing the REST Request button or selecting the corresponding “REST Test Request” option from the Insert/Append TestStep popup menu options in the TestCase editor. This will first prompt for a name and which REST Method to test:
    create-REST-test-request-selection
    The drop-down shows all REST Requests and their corresponding Methods, select which you want to use as a starting point for your TestStep.

In either ways, pressing OK generates the REST Request TestStep as specified into the target TestCase:

created-REST-test-request-step

Double-click it to open the editor which is similar to the standard REST request editor but has the Assertion and Log tabs added at the bottom:

REST-test-request-step-assertions

An overview on how to work with assertions is available here. Currently there are no REST-specific assertions, the standard assertions for response messages and XML all apply as usual.

Add assertions as desired and you are all set. Of course you can add any number of REST TestSteps to a TestCase, chaining them as desired and transferring values between response and request messages with the Property-Transfer TestStep.

Next Steps

REST Cheat Sheet

SOAP vs. REST 101: Understand the Differences

REST Resources and Methods

REST Tutorial

Mocking REST Services