一、postman简介
接口测试工具,只做功能测试
断言:
判断状态码是否为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(“这个地方写入内容”);
});
//判断json中某个键的值,value处写键名,最后的括号写键的值。
pm.test(“Your test name”, function () {
var jsonData = pm.response.json();
pm.expect(jsonData.value).to.eql(100);
});
//必须含有某一个字符串。
pm.test(“Body is correct”, function () {
pm.response.to.have.body(“response_body_string”);
});
//判断响应报文中是否含有某个字段。Content-Type=写入的字段
pm.test(“Content-Type is present”, function () {
pm.response.to.have.header(“Content-Type”);
});
//判断响应时间是否小于200毫秒,
pm.test(“Response time is less than 200ms”, function () {
pm.expect(pm.response.responseTime).to.be.below(200);
});
//判断状态码是否为列表中的其中一个
pm.test(“Successful POST request”, function () {
pm.expect(pm.response.code).to.be.oneOf([201,202]);
});
collections :测试集、测试套件。
get:选择请求方法。
save:保存在测试集中。
params 参数
bulk edit : 编辑大块
Authorization :证书
header –指的是请求头部
body ----当请求方法为post时—X-www
binary :二进制文件
Pre-request script 写脚本
Test 测试断言判断执行结果是否满足预期结果。
Envionment :环境变量
Iterations 迭代{指的是这个集合跑多少次}
Delay 延迟{指第一个请求结束等待多少ms发送第二个请求}
Jemit 和postman的使用??
变量名称: filterInput={input}
如果有多个变量用逗号隔开。
分割符—从文件中读取的分割符。
更改线程数
Csv数据文件设置-----一定要设置编码格式