Automatic Test Generation

This guide will show the basics of creating your first API test using RapidAPI Testing's automatic test generation tool.

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.

1907

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.

1916

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.

1916

Select the desired endpoint from the list on the left-hand side.

1917

Fill in the required parameters if necessary:

1065

👍

You can find the URL, API Key, Parameters, and other information from the APIs listing on the RapidAPI Marketplace

1056

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.

1896

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.

1912

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.

Running the Test

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.

1912

You can see the test result (sucess or fail) on the left-hand side:

1912

Click on a test result to view more details:

1164

📘

Now that you have created a basic test consider doing the following steps: