如果邮递员响应状态代码是500服务器错误,我如何无法通过测试? [英] how do i fail a test if postman response status code is 500 server error?
问题描述
我正在尝试建立一个发出POST请求但收到500服务器错误的测试(我看到的响应正文是意外的'T'[JSON];测试报告评估测试脚本:SyntaxError:JSON中位置0处的令牌T异常),因此对于我的所有5个测试,测试都应显示Failed.我该怎么办?
I'm trying to set up a test where I make a POST request but getting a 500 Server Error (Response Body that I'm seeing is Unexpected 'T' [JSON]; Tests reporting "There was an error in evaluating the test script: SyntaxError: Unexpected token T in JSON at position 0") and so Tests should show Failed for all 5 of my tests. What can i do?
我的一个测试甚至没有运行,它看起来像: tests [状态代码为201已创建"] = responseCode.code === 201;
One of my tests isn't even run it looks like: tests["Status code is 201 Created"] = responseCode.code === 201;
在此先感谢您的帮助. 天.
Thanks in advance for your help. Tien.
推荐答案
您可以使用以下命令检查HTTP代码不是500:
You can check that HTTP code is not 500 with following:
tests["Status code is not 500"] = responseCode.code != 500;
这是您要找的吗?
这篇关于如果邮递员响应状态代码是500服务器错误,我如何无法通过测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!