一、postman测试集合(测试套件)
1.新建一个测试集合
2.编辑测试套件的名字及注释信息
3.设置测试集合的公共参数,用到的时候可以直接通过key调用,如:{{url}}
二、通过postman进行接口测试
三、postman对接口的断言
常用的postman断言 | 解释 | 对应脚本 |
---|---|---|
Response body:Contains string | response包含字符串 | tests["Body matches string"] = responseBody.has("string_you_want_to_search"); |
Response body:Is equal to a string | response body等于指定字符串 | tests["Body is correct"] = responseBody === "response_body_string"; |
response body:JSON value check | json解析key的值进行校验 | tests["Your test name"] = jsonData.value === 100; |
status code:Code is 200 | 判断状态码 | tests["Status code is 200"] = responseCode.code === 200; |
status code:code name has string | 检查code name 是否包含内容 | tests["Status code name has string"] = responseCode.name.has("Created"); |