cookie
清除缓存
code
生成接口自动化测试脚本
响应部分
断言
断言:用于判断接口请求是否成功
最少2个:
- 状态断言:200
//状态断言:
//断言状态码为200
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
});
- 业务断言:可以有多个
//断言返回的结果中包含一个字符串
pm.test("Body matches string", function () {
pm.expect(pm.response.text()).to.include("access_token");
});
//检查返回的JOSN数据的值。
pm.test("Your test name", function () {
var jsonData = pm.response.json();
pm.expect(jsonData.expires_in).to.eql(7200);
});
//断言返回的结果等于一个字符串
pm.test("Body is correct", function () {
pm.response.to.have.body("{"errcode":0,"errmsg":"ok"}");
});
//断言响应头中是否包含Content-Type
pm.test("Content-Type is present", function () {
pm.response.to.have.header("Connection");
});
//断言接口的请求时间少于200ms
pm.test("Response time is less than 200ms", function () {
pm.expect(pm.response.responseTime).to.be.below(200);
});
导出接口用例
newman 在Linux运行
newman:专为postman而生,执行非GUI方式
命令:
newman run "e:\yongli.json" -e "e:\huanjing.json" -g "e:\quanju.json" -r cli,html,json,junit --reporter-html-export "e:\result.html"
集成Jenkins
原文:https://www.cnblogs.com/xiaoyujade/p/13268276.html