Postman - Consider Timeout as test failure

2019-08-21 08:22发布

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条回答
\"骚年 ilove
2楼-- · 2019-08-21 09:01

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

查看更多
登录 后发表回答