Sometimes your Collection tests fail—even when you expect them all to pass.
When failure occurs, you can debug your requests in two ways:
Let’s explore debugging request in an example using the Postman Echo collection.
To add Postman Echo to your Postman builder view, go to Postman Echo.
Click the Run in Postman button on the top right side of the screen. The Postman Echo collection appears in the sidebar of your Postman builder.
In your Postman builder view, click the Runner button in the left side of the header bar.
In the Collection Runner, select “Postman Echo” and click the Run Postman Echo button. (You can also select the “Environment”, “Iterations”, “Delay” (time), “Log Repsonses”, “Data”, and “Persist Variables”. But it’s not necessary for this example.) The image below shows the results of the collection run.
In the Delete Cookies
request, we expect a certain cookie to be returned by the server.
Postman Echo’s Cookies endpoint returns whatever cookies are sent to it. It also sends a JSON representation of these in the response body. We’re using this to check if a certain cookie was returned.
As you can see, this test is failing. Let’s investigate why.
As the test says, we’re expecting a cookie named foo1
to be returned as part of the response.
If you click on any request name in your collection run, you’ll notice a tooltip appear. This tooltip has useful information about to your request, information you might need to figure out what went wrong.
Expanding the Response Body
section, we can see clearly that the response does not contain the cookie we expect.
Moreover, when we expand the Response Headers
section, we see that the cookie was not sent at all. We infer something must be wrong with the way Postman Echo handles cookies. We can now go ahead and patch this up in our API and try again.
Note that only response bodies less than 300KBs are attempted to be displayed. Your response headers and bodies are never synced for security reasons.
You can control which bodies show up in this tooltip by using the Log responses
dropdown when starting a collection run.
Debugging using the Postman Console requires you to have the console open before you start your run.
For more information about the Postman Console, see Debugging and logs.
The Postman Console records all requests and displays them in a list.
Let’s find the request that’s causing problems here and expand its response headers. Here too, we see that the Postman Echo endpoint did not return a cookie, and indicates why our test is failing. We can then infer that the endpoint is misbehaving and needs to be reviewed.
Any console.log
you have in your test scripts also appears here, so you can log in the console if you’re debugging a complex test script.
For more information about collection runs, see: