2021年(10)
分类: 项目管理
2021-08-25 10:16:23
{ "errcode": 0, "errstr": "success", "post": [], "get": [], "request": [], "put": "", "header": { "Host": "echo.apipost.cn", "Connection": "keep-alive", "Content-Length": "0", "Accept": "application/json, text/javascript, */*; q=0.01", "Accept-Encoding": "gzip, deflate, br", "Accept-Language": "zh-CN", "Content-Type": "application/json", "Cookie": "PHPSESSID=n3k73k06o6ghnie4e9re4rbf0t", "Origin": "", "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1" } }
apt.assert('response.raw.status==200'); apt.assert('response.raw.type=="json"'); apt.assert('response.json.errcode==0'); apt.assert('response.raw.responseTime<100'); apt.assert('response.json.header.Host=="echo.apipost.cn"');
response.raw.status //响应状态码(200、301、404等) response.raw.responseTime //响应时间(毫秒) response.raw.type //响应类型(json等) response.raw.responseText //响应文本
response.json.data.token //也可以 response.json.data["token"]
response.headers.server //也可以 response.headers["server"]
response.cookies.PHPSESSION //也可以 response.cookies["PHPSESSION"]
apt.assert('response.raw.responseText=="test"'); // 检查响应文本是否等于test字符串 apt.assert('response.raw.responseText.indexOf("test") > -1'); // 检查响应文本是否含有test字符串
apt.assert('response.json.hasOwnProperty("errcode")'); // 检测返回json对象的是否含有errcode字段 apt.assert('response.json.errcode=="success"'); // 检测返回json对象的errcode字段是否等于success字符串 apt.assert('response.json.errcode.indexOf("success") > -1'); // 检测返回json对象的errcode字段是否含有success字符串 apt.assert('response.json.errcode!="success"'); // 检测返回json对象的errcode字段是否不等于success字符串 apt.assert('response.json.errcode>=1'); // 检测返回json对象的errcode字段是否大于1 apt.assert('response.json.errcode==null'); // 检测返回json对象的errcode字段是否是null
apt.assert('response.headers.hasOwnProperty("content-type")');
apt.assert('response.raw.status==200');
apt.assert('response.raw.responseTime>=100');
apt.assert('response.raw.type=="json"');