How to make Postman/Newman to fail a test after certain time has passed? How to make Postman/Newman to fail a test after certain time has passed? jenkins jenkins

How to make Postman/Newman to fail a test after certain time has passed?


you may have a look to newman options here : https://www.npmjs.com/package/newman#newman-run-collection-file-source-options. The interesting option is --timeout-request : it will surely fulfill your need. In Postman itself, you may test the responseTime. I recall that there is a snippet, on the right part, which looks like this:

tests["Response time is less than 200ms"] = responseTime < 200;

and which could help you as the test fails if response does not occur within the requested time.

Alexandre


If you are going to be using Jenkins pipeline you can use the timeout step to cause long running jobs to result in failure, here's on for 2 mins.

timeout(120) {  node {    sh 'newman command'  }}

Check out the "Pipeline Syntax" editor in Jenkins to generated your code block and look for other useful functions.