当前位置: 首页 - 学院 - 教程 - 其他教程 - 正文

postman怎么添加断言 postman添加断言方法

2020-11-30 09:18:15 来源:下载之家 作者:tjxz

Postman

Postman

软件类型:网页辅助 软件大小:132.22MB 软件平台:  PC  软件语言:简体

标签: Postman Postman插件

查看详情

      postman怎么添加断言?很多小伙伴不会操作,下面小编给大家带来postman添加断言方法,我们一起学习下吧。

      postman怎么添加断言 postman添加断言方法

postman怎么添加断言 postman添加断言方法

      打开上次保存的postman完成的访问百度经验的一个简单的Get请求。

      9postman-测试GET请求

postman怎么添加断言 postman添加断言方法截图

      点击Send,查看响应信息。

      这里就设置,检查响应信息里面包含:百度经验——实用生活指南

      这几个字。

      同时设置响应httpCode为200,断言响应成功。

postman怎么添加断言 postman添加断言方法截图

      点击Url下方的Tests,这里设置断言。

postman怎么添加断言 postman添加断言方法截图

      点进来后这里是空的,你如果熟悉postman的函数,可以直接手动输入,如果不熟悉,postman在右侧已经提供了tests片段。

      点击Learn more tests可以了解更多代码片段。

postman怎么添加断言 postman添加断言方法截图

      找到Response body:Contains string

      响应body包含字符串。

      点击。

postman怎么添加断言 postman添加断言方法截图

      在Tests框内出现一段代码片段,其他不用管,只需要将string_you_want_to_search字符串,替换为:百度经验——实用生活指南

      即可,而且代码片段写的很明白,从英文意思就可以了解该如何设置。

postman怎么添加断言 postman添加断言方法截图
postman怎么添加断言 postman添加断言方法截图

      找到代码片段。Status code:code is 200.

      点击。

postman怎么添加断言 postman添加断言方法截图

      生成断言httpCode为200的代码片段。

postman怎么添加断言 postman添加断言方法截图

      Ctrl+s保存一下请求的设置。

      然后点击Send发送请求,查看响应信息。

      响应中查看Tests Results。

      设置的检查全部成功。

postman怎么添加断言 postman添加断言方法截图

      以上就是postman添加断言方法,更多精彩教程尽在下载之家!