简体   繁体   English

如果邮递员响应状态代码是500服务器错误,我如何测试失败?

[英]how do i fail a test if postman response status code is 500 server error?

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. 我正在尝试设置一个测试,我发出一个POST请求,但得到500服务器错误(我看到的响应主体是意外'T'[JSON];测试报告“评估测试时出错script:SyntaxError:位于0的JSON中的意外标记T“)因此测试应显示我的所有5个测试都失败。 What can i do? 我能做什么?

One of my tests isn't even run it looks like: tests["Status code is 201 Created"] = responseCode.code === 201; 我的一个测试甚至没有运行它看起来像:tests [“Status code is 201 Created”] = responseCode.code === 201;

Thanks in advance for your help. 在此先感谢您的帮助。 Tien. 田。

You can check that HTTP code is not 500 with following: 您可以通过以下方式检查HTTP代码是否不是500:

tests["Status code is not 500"] = responseCode.code != 500;

Is this what you're looking for? 这是你在找什么?

Error 500 means either you are sending some invalid JSON in your request body or some issue with your server. 错误500表示您在请求正文中发送了一些无效的JSON,或者您的服务器出现了一些问题。 Could tell more by looking at the request and response body. 通过查看请求和响应正文可以告诉更多。

Do you have your test under any if condition? 你是否在任何条件下进行测试? I don't any reason why the test didn't run except if you have any syntax error in test section. 我没有任何理由为什么测试没有运行,除非你在测试部分有任何语法错误。

Your test script probably contains invalid JSON. 您的测试脚本可能包含无效的JSON。 Validate it using a JSON validator. 使用JSON验证器验证它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我在 Postman 中测试时,AWS Lambda function 可以使用,但是当我尝试在我的 Z217C80CED5A5D142B090C3Z 中实施时,我会得到状态代码 - AWS Lambda function works with when I test in Postman, but when I try to implement in my ReactJS I get status code 500 向 Asp.Net Core Web Api(3.1 版)发送 POST 请求时,我从 POSTMAN 获取状态 500 代码 - I am getting Status 500 code from POSTMAN when sending POST request to Asp.Net Core Web Api (version 3.1) Axios POST 请求失败,错误状态代码为 500:内部服务器错误 - Axios POST request fails with error status code 500: Internal Server error 如果服务器返回502错误,如何读取HTTP响应? - How do I read a HTTP response if the server returned a 502 error? 使用Postman在Azure上出现500 Internal Server Error POST请求 - 500 Internal Server Error POST request on Azure using Postman 如何查看进入我的 Postman 模拟服务器的请求? - How do I view a request coming into my Postman mock server? 我将字符串发布到后端,但后端返回状态码500:View函数未返回响应 - I'm posting my a string to my backend but the backend returns a status code 500: View function did not return a response Flutter:错误:内部服务器错误,代码500 - Flutter: Error: Internal Server Error, Code 500 状态码 200 在服务器上没有响应 - Status code 200 without response on the server Python请求模块后返回状态码500错误 - Python requests module post return status code 500 error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM