<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: bwurapidapi</title>
    <description>The latest articles on DEV Community by bwurapidapi (@bwurapidapi).</description>
    <link>https://dev.to/bwurapidapi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F227248%2F5642c183-ab31-4c2a-9502-19e851f41de0.png</url>
      <title>DEV Community: bwurapidapi</title>
      <link>https://dev.to/bwurapidapi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bwurapidapi"/>
    <language>en</language>
    <item>
      <title>API Testing Tutorial: API Testing with RapidAPI</title>
      <dc:creator>bwurapidapi</dc:creator>
      <pubDate>Wed, 21 Oct 2020 19:33:44 +0000</pubDate>
      <link>https://dev.to/bwurapidapi/api-testing-tutorial-api-testing-with-rapidapi-3n62</link>
      <guid>https://dev.to/bwurapidapi/api-testing-tutorial-api-testing-with-rapidapi-3n62</guid>
      <description>&lt;p&gt;Watch the video tutorial for a walkthrough of the RapidAPI Testing. Then follow the step-by-step tutorial below to create your own API and start testing!&lt;/p&gt;

&lt;a href="https://rapidapi.com/blog/wp-content/uploads/2020/10/APIs-_-RapidAPI-Testing.mp4" rel="noopener noreferrer"&gt;https://rapidapi.com/blog/wp-content/uploads/2020/10/APIs-_-RapidAPI-Testing.mp4&lt;/a&gt;

&lt;h1&gt;
  
  
  Start Testing with RapidAPI
&lt;/h1&gt;

&lt;p&gt;In this tutorial, you'll learn how to &lt;a href="https://rapidapi.com/products/api-testing/" rel="noopener noreferrer"&gt;test an API using RapidAPI Testing&lt;/a&gt;. First, we'll create a new API from an API specification file. Then, we will walk through how to quickly generate tests using the testing dashboard. Towards the end, we'll talk about how you can set up testing environments, schedule tests, and set alerts for failed tests.&lt;/p&gt;

&lt;h2&gt;
  
  
  Download API Spec
&lt;/h2&gt;

&lt;p&gt;This tutorial uses a Swagger &lt;a href="https://rapidapi.com/blog/how-to-document-your-api/" rel="noopener noreferrer"&gt;API Specification&lt;/a&gt; for an example API named Pet Store. You can click the link below to download the &lt;a href="https://rapidapi.com/blog/api-glossary/json/" rel="noopener noreferrer"&gt;JSON&lt;/a&gt; file. &lt;a href="https://rapidapi.com/blog/wp-content/uploads/2020/10/swagger-pet-store.json" rel="noopener noreferrer"&gt;Download Pet Store Swagger API Spec&lt;/a&gt; Now that you have the file, we are ready to create our API on the RapidAPI Testing dashboard.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a New API
&lt;/h2&gt;

&lt;p&gt;Navigate to the testing dashboard at &lt;a href="https://rapidapi.com/testing/dashboard" rel="noopener noreferrer"&gt;rapidapi.com/testing/dashboard&lt;/a&gt;. You may need to sign in to your RapidAPI account. After signing in, select &lt;strong&gt;Create API&lt;/strong&gt; in the top right of the page. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-13-at-1.55.06-PM-1024x348.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-13-at-1.55.06-PM-1024x348.png" alt="Create new api button"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;In the pop-up, enter the new API's information:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Select the &lt;strong&gt;Context&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;  Enter an appropriate API name (&lt;strong&gt;Pet Store&lt;/strong&gt;)&lt;/li&gt;
&lt;li&gt;  Select the API specification file&lt;/li&gt;
&lt;li&gt;  Choose OpenAPI for &lt;strong&gt;Definition type&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Click &lt;strong&gt;OK&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-13-at-1.57.47-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-13-at-1.57.47-PM.png" alt="new API form "&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The new API should appear on your testing dashboard alongside any existing APIs. Also, it will appear in the account context that you chose when creating the API. Click on the new API tile to enter the Pet Store API testing dashboard.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build a Test
&lt;/h2&gt;

&lt;p&gt;On the next page, click &lt;strong&gt;Create Test.&lt;/strong&gt; Name the test &lt;em&gt;Add Pet&lt;/em&gt;. After you name the test, you'll be taken to the user interface for building tests. You have the option to build tests manually. However, it's easier to use the &lt;strong&gt;Request Generator&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Inspect Request Generator
&lt;/h3&gt;

&lt;p&gt;At the bottom of the &lt;em&gt;Add User&lt;/em&gt; test dashboard. Click on the highlighted &lt;strong&gt;Request Generator&lt;/strong&gt; bar. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-13-at-2.29.09-PM-1024x365.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-13-at-2.29.09-PM-1024x365.png" alt="request generator bar"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;After clicking on the Request Generator, a new pane will appear that has three sections. On the left, you'll see your endpoints. If you click on an endpoint, the middle pane will populate with the information (and sample data) for that route. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-7.41.40-AM-1024x409.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-7.41.40-AM-1024x409.png" alt="request generator left pane with add pet selected"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Click the &lt;strong&gt;Send&lt;/strong&gt; button in the middle section next to the route's URL. You should receive a successful response in the right section if your API has valid sample data. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-7.44.31-AM-289x300.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-7.44.31-AM-289x300.png" alt="Successful pet store response"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now that you have received a response, we can add this outcome to our &lt;em&gt;Add Pet&lt;/em&gt; test. Click &lt;strong&gt;Add to Test&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Select Assertions
&lt;/h3&gt;

&lt;p&gt;A new pop-up will appear asking us what parts of the response we want to add to the test. Here, we toggle properties on-or-off. If a property is _on, _then it will be added to the test. Furthermore, we can use the dropdown on the right to modify the type of assertion. In the image below, I have selected various assertions that I feel fit the properties best. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-7.46.50-AM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-7.46.50-AM.png" alt="test assertions popup"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Once we finish checking out assertions, click &lt;strong&gt;OK&lt;/strong&gt; at the bottom of the pop-up. Close the &lt;strong&gt;Request Generator&lt;/strong&gt; and observe all the assertions that we have now added, as individual steps, to our test. You use the drag-and-drop feature to modify the order of test steps. Additionally, you can modify the content of steps by selecting the angle icon on the right of each step. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-7.55.33-AM-1024x288.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-7.55.33-AM-1024x288.png" alt="angle bracket selected"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now, we are ready to run the test.&lt;/p&gt;

&lt;h3&gt;
  
  
  Run Test &amp;amp; View Results
&lt;/h3&gt;

&lt;p&gt;At the top right of the &lt;em&gt;Add Pet&lt;/em&gt; test dashboard, click &lt;strong&gt;Save &amp;amp; Run. &lt;/strong&gt; The test runs successfully, and the result should appear in the bottom left of the test dashboard. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-8.04.45-AM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-8.04.45-AM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on the new result to view the &lt;strong&gt;Execution Report&lt;/strong&gt;. The report displays the test conditions and details aspects of individual steps. For example, the &lt;code&gt;apiResponse.data.id&lt;/code&gt; attribute is of type number, but the value is also displayed in the report. Furthermore, you can compare the response schema with your test schema by selecting &lt;strong&gt;Show Details&lt;/strong&gt; for steps. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-12.16.03-PM-1024x367.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-12.16.03-PM-1024x367.png" alt="test details"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If a test fails, the value that caused the test to fail is displayed in the &lt;strong&gt;Execution Report&lt;/strong&gt;. This makes it easier to find and fix errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Chain Requests Together
&lt;/h2&gt;

&lt;p&gt;Some APIs have endpoints that work together or use the same data. We can test API functionality and integrity by chaining different requests together.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Pet
&lt;/h3&gt;

&lt;p&gt;First, navigate back to the &lt;em&gt;Pet Store Tutorial API&lt;/em&gt; dashboard, and create a new test. Name the test &lt;em&gt;Add-Get Pet&lt;/em&gt;. Then, in the &lt;strong&gt;Request Generator&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Select the &lt;em&gt;addPet&lt;/em&gt; endpoint&lt;/li&gt;
&lt;li&gt;  Click on the &lt;strong&gt;Body&lt;/strong&gt; tab, underneath the URL, and select &lt;strong&gt;json&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;  Send a request to get a response&lt;/li&gt;
&lt;li&gt;  Select &lt;strong&gt;Add to Test&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This time, we are only going to test whether the &lt;strong&gt;status&lt;/strong&gt; parameter returns a 200 status code. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-12.27.21-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-12.27.21-PM.png" alt="assert test status code is 200"&gt;&lt;/a&gt; Click &lt;strong&gt;OK &lt;/strong&gt;to add it to our test.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Test Variables
&lt;/h3&gt;

&lt;p&gt;It's advantageous to incorporate test variables into chained requests so that the value can be updated—or tested—quickly. In this example, we want to use a common ID value to create and then get a pet. There are two ways to set a test variable. One way is to select the &lt;strong&gt;Settings&lt;/strong&gt; option in the navigation bar and add variables to test context in the &lt;strong&gt;Test Variables&lt;/strong&gt; section. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.03.51-PM-1024x349.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.03.51-PM-1024x349.png" alt="test variable section in settings"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The second way is to create a step in the test where you set a variable. Back in the &lt;em&gt;Add-Get Pet&lt;/em&gt; test, click the &lt;strong&gt;Add Step &lt;/strong&gt;area to add a new step. You will see a list of different types of steps that are available. Select the &lt;strong&gt;Set Variable&lt;/strong&gt; option. Drag this new step to the top of our steps, and open the step editor by clicking the angle-down icon on the right side of the step. For the &lt;strong&gt;Key&lt;/strong&gt;, enter &lt;em&gt;petId&lt;/em&gt;, and for the &lt;strong&gt;Value&lt;/strong&gt; enter &lt;em&gt;9222645476172562000&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.00.36-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.00.36-PM.png" alt="set variable"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;This &lt;em&gt;petId&lt;/em&gt; test variable will now be available in later steps using the syntax &lt;code&gt;{{petId}}&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using Test Variables
&lt;/h3&gt;

&lt;p&gt;In the &lt;em&gt;Add Pet&lt;/em&gt; request, modify the JSON body to include the petId variable. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.00.54-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.00.54-PM.png" alt="petId variable in JSON body"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Next, open up the &lt;strong&gt;Request Generator&lt;/strong&gt; again and select the &lt;em&gt;getPetById&lt;/em&gt; endpoint. Replace the last item (&lt;code&gt;undefined&lt;/code&gt;) in the URL with the value &lt;code&gt;{{petId}}&lt;/code&gt;. Then, send the request. It's ok if it fails. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.18.20-PM-1024x227.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.18.20-PM-1024x227.png" alt="petId to URL"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Add to Test&lt;/strong&gt;. Then, unselect all items from the pop-up so only the HTTP request is added to the test. Next, add a new step that asserts the status code for our GET request is 200. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.22.29-PM-1024x387.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.22.29-PM-1024x387.png" alt="add assertion"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Finally, assert that the ID returned in the response is the same as the ID that we set at the beginning of the test. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.02.37-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.02.37-PM.png" alt="set assertion for pet id at the end of the steps"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The full test should now have the following steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Set test variable &lt;em&gt;petId&lt;/em&gt; to 9222645476172562000&lt;/li&gt;
&lt;li&gt; Send a POST request to add a pet (with &lt;em&gt;petId&lt;/em&gt; variable in JSON body)&lt;/li&gt;
&lt;li&gt; Assert that the response is equal to 200&lt;/li&gt;
&lt;li&gt; Send a GET request, using the &lt;em&gt;petId&lt;/em&gt; variable to fetch the new pet.&lt;/li&gt;
&lt;li&gt; Assert that the status is 200&lt;/li&gt;
&lt;li&gt; Assert that the returned ID for the pet is equal to the &lt;em&gt;petId&lt;/em&gt; variable.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.28.32-PM-1024x479.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.28.32-PM-1024x479.png" alt="all the steps for this test"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Click &lt;strong&gt;Save &amp;amp; Run&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.29.48-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.29.48-PM.png" alt="execution report for chained test"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The test should be successful. Next, let's take a look at how to create testing environments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Environments
&lt;/h2&gt;

&lt;p&gt;To create environments, click on the &lt;strong&gt;Settings&lt;/strong&gt; icon in the left navigation. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.31.17-PM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.31.17-PM.png" alt="settings button on left navigation bar"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;In the &lt;strong&gt;Test Environments&lt;/strong&gt; section, click on the &lt;strong&gt;+&lt;/strong&gt; icon to name your new environment. Environments show up as tabs along the top of the &lt;strong&gt;Test Environments&lt;/strong&gt; section. You define environment variables the same way you define test variables. For this example, you can change the URL for your tests by specifying the &lt;em&gt;protocol&lt;/em&gt; and &lt;em&gt;domain&lt;/em&gt;. I specified two variables for each environment. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.36.48-PM-1024x277.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.36.48-PM-1024x277.png" alt="production environmnet"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-07-at-11.09.34-AM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-07-at-11.09.34-AM.png" alt="development environment"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Back in the individual tests, I can modify the URLs for each request and select the environment I want to use before I execute a test. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.39.52-PM-1024x437.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.39.52-PM-1024x437.png" alt="using environments in a test"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;With the environment variables, we can share variables across different tests. With test variables, we can scope values that are important to a specific test.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scheduling Tests and Setting Alerts
&lt;/h2&gt;

&lt;p&gt;With RapidAPI Testing, you can schedule tests to run from different locations around the world and with different environments. To schedule a test, select the test that you want to schedule from the dashboard. Click on the &lt;strong&gt;Schedule &lt;/strong&gt;option in the side navigation. Choose the:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Frequency&lt;/li&gt;
&lt;li&gt;  Environment&lt;/li&gt;
&lt;li&gt;  Locations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.42.26-PM-1024x502.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.42.26-PM-1024x502.png" alt="scheduling tests"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now that your test is scheduled, go to the main API test settings. This is the same location where we defined test environments. You can select to either receive &lt;strong&gt;Email&lt;/strong&gt; or &lt;strong&gt;SMS&lt;/strong&gt; alerts when a test for this API fails. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.45.16-PM-1024x313.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Frapidapi.com%2Fblog%2Fwp-content%2Fuploads%2F2020%2F10%2FScreen-Shot-2020-10-14-at-1.45.16-PM-1024x313.png" alt="setting alerts"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this brief tutorial, we covered how to test your API using RapidAPI Testing. Also, we looked at making basic assertions. However, there are a variety of different types of test steps that can be utilized to test more complex scenarios, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Custom code&lt;/li&gt;
&lt;li&gt;  Looping over responses&lt;/li&gt;
&lt;li&gt;  Logical assertions (If/Else checks)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that you understand the basics of how to test APIs, I encourage you to try it out with your own API.&lt;/p&gt;

</description>
      <category>api</category>
      <category>testing</category>
      <category>tutorial</category>
      <category>qa</category>
    </item>
  </channel>
</rss>
