Solution: Testing APIs
Let’s write and run the Credit-Check Postman test collection.
For this challenge, the task was to create a Postman test collection for the Credit-Check API project and write two tests: a happy-path test for the home
resource (http://localhost:8181/
) and a sad-path test for the form
resource (http://localhost:8181/form/
).
Create the “Credit-Check” collection in Postman
First, we need to create a new test collection in Postman. Let’s name it “Credit-Check.” In the Postman client, click the “+ New Collection” link in the left sidebar, enter “Credit-Check” in the “Name” field, and then click the “Create” button in the bottom-right corner of the dialog box.
Add the “home” test
Click the three dots near the collection name and select “Add Request” from the dropdown menu. Enter “home” as the “Request Name” and click the “Save” button. Next, click the “Home” test in the left sidebar to bring it up to the main editor view. Now we can add the “Request URL” and click the “Send” button. We should get a response body back that looks like this:
Get hands-on with 1200+ tech skills courses.