Postman - Consider Timeout as test failure

笑着哭i 提交于 2020-01-06 09:52:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!