哈尔滨网站建设的公司哪家好,网站百度终端适配代码,益阳网站建设哪里好,wordpress auto spinner在做接口测试的时候#xff0c;会对接口进行断言#xff0c;一个完整的接口测试#xff0c;包括#xff1a;请求-获取响应正文-断言。
一、apipost如何进行断言
apipost的断言设置实在后执行脚本中进行编写的。apipost本身提供了11中断言#xff1a;
apt.asser…在做接口测试的时候会对接口进行断言一个完整的接口测试包括请求-获取响应正文-断言。
一、apipost如何进行断言
apipost的断言设置实在后执行脚本中进行编写的。apipost本身提供了11中断言
apt.assert(‘response.raw.responseText“test”’);测试响应内容是否为test
apt.assert(‘response.raw.status200’);测试响应码是否为200
apt.assert(‘response.raw.type“json”’);测试响应内容格式是否为json
apt.assert(‘response.raw.responseTime100’);测试响应时间是否大于100ms
apt.assert(‘response.json.errcode1’);测试响应Json对象的errcode属性是否为1
apt.assert(‘response.json.errcode!1’);测试响应Json对象的errcode属性是否不为1
apt.assert(‘response.json.errcode1’);测试响应Json对象的errcode属性是否为大于等于1
apt.assert(‘response.json.errcodenull’);测试响应Json对象的errcode属性是否为null
apt.assert(‘response.json.errcode!null’);测试响应Json对象的errcode属性是否不为null
apt.assert(‘response.headers[“server”] “nginx”’);测试响应头server是否为nginx
apt.assert(‘response.headers[“content-encoding”] “gzip”’);测试响应头content-encoding是否为gzip 二、如何查看断言
接口中查看断言 流程测试中查看断言 其中的成功和失败是代表的流程测试执行成功了几条执行失败了几条。
三、自定义断言
apipost脚本支持js语句我们可以自定义断言比如自定义响应值中json返回的code值是否等于200
apt.assert(‘response.json.code200’);