如果邮递员响应状态代码是 500 服务器错误,我该如何通过测试? [英] how do i fail a test if postman response status code is 500 server error?

查看:15
本文介绍了如果邮递员响应状态代码是 500 服务器错误,我该如何通过测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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?

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.

解决方案

You can check that HTTP code is not 500 with following:

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

Is this what you're looking for?

这篇关于如果邮递员响应状态代码是 500 服务器错误,我该如何通过测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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