邮递员-将超时视为测试失败 [英] Postman - Consider Timeout as test failure

查看:120
本文介绍了邮递员-将超时视为测试失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Postman v5.5.3,并尝试运行带有测试的请求集合并报告结果。

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.

我有2条断言:

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);
});

如果我将Postman XHR超时设置为10000 ms,并且Collection Test Runner遇到超时,它会不要认为这是一个失败的测试。

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.

是否有一种方法可以测试超时,从而使超时在Collection Test Runner测试结果中显示为测试失败?

If there a way to "test for timeouts" so that timeouts show as test failures in the Collection Test Runner Test Results?

推荐答案

请求超时是为了确保请求在规定的ms内返回响应。

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.

您可以使用Newman及其关联的请求事件处理程序纽曼事件

You can achieve this programatically using Newman and its associated 'request' event handler Newman events

这篇关于邮递员-将超时视为测试失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆