RapidAPI Testing's Automatic Testing Generation tool infers the properties of an API, and lets you create a test based on the properties in just a few moments.
We will test some endpoints in the Spoonacular API, so if you want to follow along subscribe to the API for free here.
RapidAPI Testing Link
To get started, navigate to https://rapidapi.com/testing/.
Once you have signed up or logged in to your RapidAPI account, you will be able to see all your APIs. You can click on one of them to add tests to or create a new API to test.
Once you click an API, go ahead and create a test. You can give it any name you'd like. Click the pencil icon in the test row to edit it.
In this test, we are going to test the Extract Recipe from Website endpoint in the API.
To connect to the API, open the request generator at the bottom of the screen.
Select the desired endpoint from the list on the left-hand side.
Fill in the required parameters if necessary:
You can find the URL, API Key, Parameters, and other information from the APIs listing on the RapidAPI Marketplace
Once you make the request and see the result, press the blue "Add to Test" button to add this request to the test flow. This will prompt you to select what assertions to make on this request. You can select all, some, or none. For each part of the response, you can choose whether to assert:
- That it exists
- That it is of a certain type
- That it has a certain value
These are useful for different parts of the response. For instance, you may want to validate that the status code is always 200, but if there is a "fullName" parameter you'll just want to verify that it's a string.
Click "OK" to add the assertions to the test. Now, you'll be able to see all the steps added in the visual editor. The first step is actually making the request, and subsequent steps make assertions about the content of the response.
You can also go ahead and add more steps to your test by clicking the "+ Add Step" button. These can be more assertions about the response, more API calls, and more. If you want to change the order of the steps you can do so by dragging and dropping them around.
For a test to be successful, all steps of the test must pass. Save and run the test by clicking the button in the top right corner.
You can see the test result (sucess or fail) on the left-hand side:
Click on a test result to view more details:
Now that you have created a basic test consider doing the following steps:
Updated about a month ago