Adding an API Step to your Test
Test cases are not just a set of steps performed on your screen. Today, test cases require creating runtime test data from API responses and using that data in subsequent steps (or deleting data after the test has completed execution). This makes automated tests reusable and resilient.
To add an API step to a test case:
- Log in to your Sofy account.
- Select Device Lab from the left navigation bar.
- Acquire and launch a device.
- Start recording a test case.
- Click the API Step Icon at the bottom of the action bar to the right of the device screen. This will open the API Step Modal.
- Specify the request URL and select the type of request. Sofy currently supports GET, POST, PUT, PATCH, and DELETE.
- Click Send.
- You can also add up to 10 test variables from the values received in the response (for example, if you want to execute sequences of API calls based on data obtained during the test execution). Test variables will be assigned a value during the test run once the test case is saved. To add a test variable:
- Click on any value in the response.
- Click the + symbol next to the value. The test variable will appear under the Test Variables section.
- Update the Regex (regular expression) field if you want to save only the relevant part as a variable. For example, you may want to store only the second word of a given string.
- While configuring your API step, you can also add new path variables, headers (like bearer tokens), and query parameters. To do this:
- Select the Headers, Query Params, or Path Variables tab under the request setting.
- Click Add new or the + button at far right.
- Name and select a variable for the header, query param, or path variable. You can also select a test variable you created in the API step.
- Once you’re done configuring your API step, click Add API Step.