安装postman 地址getpostman.com
安装newman 地址getpostman.com/docs/v6/postman/collection_runs/command_line_integration_with_newman
在全局变量中存入通用函数;assert值为var code_01=responseCode.code;var time_01=responseTime;if(code_01>=500){tests['服务器无响应---'+code_01]=false;tests['错误']=false;tests['返回body---'+responseBody]=false;}if(code_01>=400 && code_01<500){ tests['语法有误---'+code_01+'---响应时间为---'+time_01+'ms']=false;tests['错误']=false;tests['返回body---'+responseBody]=false;}if(code_01>=200 && code_01<300){tests['正常响应---'+code_01+'---响应时间为:'+time_01+'ms']=true;}
在每一个postman的tests断言里加入eval函数直接引用,eval(globals.assert);自动判断响应状态码,400到500,500以上都会报错的断言。
然后用newman跑自动化脚本,在产生的日志里,轻松找到报错接口,不用一个一个去找了。
安装newman之前要安装Node.js 详情见getpostman.com/docs/v6/postman/collection_runs/command_line_integration_with_newman