is there any option to verify of all api in the collection is getting 200 in response .
without going to each api and write test block to check status of it?
as its currently getting status 500 and still accepting.
@saikatharryc This can be done with a test inside a collection level script, like so:
pm.test('should be 200 OK', function () {
pm.response.to.be.ok;
});
More details here: https://www.getpostman.com/docs/v6/postman/scripts/test_scripts#adding-a-test-script-to-a-collection-or-folder
@kunagpal i mentioned that, already. that is the other way i have to write inside every api i guess.
it could be a feature request if currently cant handled by newman.
@saikatharryc My bad, I wasn't clear enough. As mentioned above, you can add tests at a collection level, which will be run after each request without having to duplicate the same code all over the place 馃槃
So, the following collection will always run the 200 OK tests for each request, regardless of the level of nesting/number of requests in the collection:
{
"info": {
"_postman_id": "10fb2593-5175-4c4a-aff4-1bba6ef4d724",
"name": "Collection with scripts",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Echo GET",
"request": "https://postman-echo.com/get"
}
],
"event": [
{
"listen": "test",
"script": {
"id": "ccd3c0f3-62d1-4c69-bad2-2169d429afdf",
"type": "text/javascript",
"exec": [
"pm.test('Should be 200 OK [Collection level test, runs after every request]', function () {",
" pm.response.to.be.ok;",
"});"
]
}
}
]
}
In the example above, notice that the event property is at the root level of the collection, as opposed to the usual location inside elements of the item array.
Most helpful comment
@saikatharryc My bad, I wasn't clear enough. As mentioned above, you can add tests at a collection level, which will be run after each request without having to duplicate the same code all over the place 馃槃
So, the following collection will always run the 200 OK tests for each request, regardless of the level of nesting/number of requests in the collection:
In the example above, notice that the
eventproperty is at the root level of the collection, as opposed to the usual location inside elements of theitemarray.