今日所讲 ———自动话测试

【1】postman中断言操作·

(以QQ测吉凶来近举例):

状态码 :pm.response.to.have.status(200);成功

返回数据是否包含字符串:pm.test("Body matches string",function () {

pm.expect(pm.response.text()).to.include("success1212")

}):失败

断言验证json中的key和value数据:pm.test("Your test name",function () {

var jsonData = pm.response.json();

pm.expect(jsonData.reason).to.eql("fail");

});成功

响应头断言:pm.test("Content-Type is present",function(){

pm.response.to.have.header("hest");

pm.test("Response time is less than 200ms",function(){

pm.expect(pm.response.responseTime).to.de.delow(600);

})

})

【2】postman中批量操作

将要测试地数据倒出text到桌面,

点击右键点击RUN弹出集合运行地弹框他会给我们提示需要在什么环境,(iteations)迭代执行多少次,(Delay)延迟,(logResponses)默认是显示所有地信息

导入postman中点击执行

【3】导入和导出脚本

(1)postman+newman+jenkins:接口自动化测试

(2)简介:Newman是postman推出地一个node。js库,newman可以方便地运行和测试合,并用之前构造接口自动化测试和持续集成

(3)安装和配置node.js :第一步:验证node。js是否安装成功 :node -v;安装newman:npm install -g newman ;配置:newman环境;验证:newman是否安装成功

 newman -v

(4)newman地命令:常见地参数 -e: 使用环境变量 -g: 使用全局变量 -d: 使用csv,text,json数据驱动 -n:循环次数 -r :cli,html,json,junit --reporter-html-export;命令:newman run C:\Users\jack\Desktop\postman_collection.json

(5)生成测试报告:首先下载html:npm install -g newman-reporter-html

newman run C:\Users\jack\Desktop\postman_collection.json -r html --reporter-htmlexport r

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值