Skip to main content

Sauce Labs API Testing Quickstart

As the number of APIs communicating with microservices in apps continues to increase, many bugs cannot be captured by UI testing alone. Our API Testing and Monitoring solution combines automated testing, reporting, debugging, diagnostics, and immediate data-driven insight in a centralized platform.

Running a functional test on an API takes seconds and will display a pass/fail status as well as the cause(s) for any failures, such as a broken endpoint, API flow, or a bug in the app itself. You can then reuse functional tests as end-to-end monitoring tests that run continuously, thereby maintaining accurate and reliable feedback loops. And by developing APIs in parallel with your testing, you can accelerate working and improve quality throughout development, staging, and production.

This Quickstart guide will get you up and running with a functional API Test. Let's get started!

What You'll Need

note

If your APIs are behind a firewall, you'll need to set up a Sauce Connect Proxy tunnel before proceeding.

Create Project

  1. Log in to Sauce Labs, then click API Testing.

  2. From the list of test creation methods, click Use HTTP Client.
    Enter API URL

Returning Users

If you're seeing an existing list of Projects instead of the landing page shown above, click Create Project instead.
Create Project

  1. In the Create a New Project window:
    • Set the Create from dropdown to blank project.
    • Enter your Project Name.
    • Optionally, you can add Tags, a Description, Notes. For the purpose of this Quickstart, leave Access as-is.
    • Click Save when you're finished.
      Create a Project UI

Create Test

For the purpose of this Quickstart, we'll test a GET call from Dog CEO, a public API that generates a list of dog breeds.

In the HTTP Client > Enter request URL field, enter https://dog.ceo/api/breeds/list/all:

Enter API URL

Send Request

Click Send to submit this HTTP request.
Enter API Request save

The JSON response in this case, a list of dog breeds will populate in the Body section along with a 200 OK success status.
API Request success

Generate Test

  1. Click Generate Test.
    Generate Test

  2. In the New Test window:

    • Enter your Test Name.
    • Optionally, you can add a Description and/or Tags.
    • Click Create Test when you're finished.
      Create Test

This will generate a series of assertions for this specific API request.

tip
Viewing your test

Visual view shows your test as UI components:
Sample Test Visual View

Code view displays it as code:
Sample Test Code View

Run Test

  1. Click the Run button to run your test.
    Run Test

  2. In the right-hand nav, under Test Runs, you'll see that a new line item has populated with the name of your test. If successful, you'll see a green checkmark indicator and Completed with success message.
    Test Runs Section

View Test Results

  1. To view your test results, hover your mouse over your test line item and click Open report document.
    Open Test Results

  2. Your test report will open in a new browser tab. The report displays granular test information that's helpful for debugging any failures (more info).
    Test Results Page

Publish Your Test

Our API Testing interface has a unique working copy/published copy workflow that allows you to edit a test without affecting the active (already published) version. Here's how to publish the working copy of your test.

  1. Once you've finish reviewing and/or editing your test, navigate to the Unpublished changes section, where it states that your test is currently unpublished.
    Unpublished Test

  2. Click the Publish button to publish your working copy.
    Published Test

Optional Next Steps

Sauce Labs API Testing has a full suite of tools that enables comprehensive continuous integration testing.