一、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"); |
