If your web service is updated, you may need to change test cases and requests in ReadyAPI. ReadyAPI offers the Refactor Definition command that simplifies this task. The command invokes a dialog box. Use it to set a correspondence between existing and new resources, methods and requests, as well as their parameters. Then, ReadyAPI will automatically update the requests and test steps in your project so that they match the updated specification.
|The refactoring feature does not affect the REST request bodies. It changes the request parameters only.|
Note: If you do not have a WADL or Swagger/OpenAPI definition for your API (for example, if you created a project from an endpoint), you will not be able to perform REST refactoring.
To use refactoring, you need the SoapUI license.
Switch to Projects.
Do any of the following:
Right-click your web service in the Navigator panel and select Refactor Definition from the context menu:
– or –
Select your web service in the Navigator panel and click Refactor on the toolbar:
– or –
Select your web service in the Navigator panel and choose API > Refactor Definition from the main menu:
The Refactor Definition dialog will appear.
Use the Refactor Definition dialog to select the update definition to be used during refactoring. The OpenAPI, Swagger, and WADL formats are allowed:
Enter the definition URL or file name in the Definition URL edit box.
Use the Definition Format settings to specify the format of the definition you are loading.
Select Create New Requests to create new requests for any new methods.
If the definition file specifies multiple services, select the one you need:
ReadyAPI will load and analyze the new definition. In the subsequent dialog, set a correspondence between old and new operations.
In the Refactoring REST Definitions dialog, specify which existing resources, methods and requests match new ones:
The dialog displays old items (resources, methods or requests) on the left and new items on the right. ReadyAPI automatically matches the old items with the new ones. The old items that do not match the new ones appear in red, while the new items that do not match the existing ones appear in blue.
Match existing resources, methods and requests with new ones in the following way:
To indicate that an existing resource, method or request matches a new one, you connect them. To do that, select an item in one panel, then select the matching item in the opposite panel and click Connect:
If the connected resource, method or request does not match the new one, disconnect them. To do that, select an item in one of the panels (ReadyAPI will select the connected item in the opposite panel automatically) and click Disconnect:
When you click Next, ReadyAPI will do the following:
If some existing resource, or its method, or a request matches the new resource, method or request (that is, if the dialog shows a thin grey line between them automatically, or if you’ve connected them manually in the dialog), then ReadyAPI will update existing items with the new item data. At that, existing child methods and requests that don’t have new matching items will not be changed. Also, ReadyAPI will add new methods and requests to the existing resource.
If neither existing resource, nor its methods and requests match any new resource, method or request, the existing item(s) are deleted.
If a new resource and its methods and requests don’t match any existing item, ReadyAPI will add these new items to the service definition stored in your project.
After you match all the needed items, click Next.
ReadyAPI displays the Refactoring REST Definitions dialog:
The dialog shows the differences between the current and new versions of the linked items. Review the suggested changes and adjust the final variant, if needed.
For linked methods, specify how ReadyAPI should treat representations. Select Overwrite to replace representations with the updated versions, or select Ignore to keep the current representations.
If a parameter is absent in the new definition, select what ReadyAPI should do: remove the parameter or link it with one of the new parameters. In the latter case, ReadyAPI will replace the absent parameter with the linked one. In order not to lose the current value of the parameter, make sure to select the Keep existing value option in the subsequent Parameters Refactoring dialog.