Writing a Sad-Path Test in Postman
Learn how to write a sad-path test in Postman.
We'll cover the following
Overview
In this lesson, we’ll write up a sad-path test for the BigCo API. For example, let’s create a test that confirms we can’t add a new company record if we’re missing required properties.
First, we can add a new request to the Company API Home Tests collection. From the main Postman interface, click the three dots near the collection name in the left sidebar and select “Add Request” from the dropdown menu. In the dialog box that appears, type “Company Create (missing properties)” as the request name and click the “Save” button.
You’ll now see the new request added to the collection (in the left sidebar). Click that request to bring it into the main editor and enter the following in the “Request URL” field: http://company-atk.herokuapp.com
. Also, select POST
from the drop-down menu to the left of the URL. Save this request to your collection and click the “Send” button to confirm that the request actually works. We should see an error message in the “Body” tab of the main display telling us the request has been completed as expected.
Writing tests
Now it’s time to write the tests. Click the “Tests” tab under “Request URL” field and add the following text in the editor:
Get hands-on with 1200+ tech skills courses.