问题
I am using Postman v5.5.3 and trying to run a collection of requests with tests and report the results.
I would like a TIMEOUT to be considered a test failure. This is not happening right now.
I have 2 asserts as:
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
pm.test("Response time is less than 1000ms", function () {
pm.expect(pm.response.responseTime).to.be.below(1000);
});
If I set the Postman XHR timeout to 10000 ms and the Collection Test Runner encounters a timeout, it does not consider this a failed test.
It seems that timeouts short-circuit the test stack and immediately drop out.
If there a way to "test for timeouts" so that timeouts show as test failures in the Collection Test Runner Test Results?
回答1:
Request timeout is to ensure requests returns back with the response within provided ms.
Since the timeout occurs waiting for the request to respond within that time no response is generated, and so nothing to be asserted on response.
You can achieve this programatically using Newman and its associated 'request' event handler Newman events
来源:https://stackoverflow.com/questions/48867360/postman-consider-timeout-as-test-failure