設置環境變量 pm.environment.set("key","value")json
獲取環境變量 pm.environment.get("key")app
清除環境變量 pm.environment.unset("key")ide
發送http請求 pm.sendRequest(request,function(err,res){})url
示例:spa
var data = {字符串
"file": {get
"title": "sahjf",string
"fileB64": res.data.file.fileB64,it
"fileType": fileType,io
"fileDesc": "簽章"
}
}
const echoPostRequest = {
url:'http://127.0.0.1:13001/mssg2/enterprise/fileVerify',
method:'POST',
header:'Content-Type:application/json',
body:{
mode:'raw',
raw :JSON.stringify(data)
}
}
pm.sendRequest(echoPostRequest,function(err,res){
pm.test("Body matches string", function () {
pm.expect(res.text()).to.include("成功");
});
})
5. 斷言:返回結果中包含某個字符串
pm.test(「Body matches string」, function () {
pm.expect(pm.response.text()).to.include(「string_you_want_to_search」);
});
6.轉換返回結果,並獲取某個字段內容
返回結果:
{
"status": 200,
"message": "成功",
"data": {
"file": {
"fileB64": "xxx"
}
}
}
獲取返回結果中fileB64的值:
var res = pm.response.json()
res.data.file.fileB64 ---這個爲要獲取的值