設定環境變數 pm.environment.set("key","value")
獲取環境變數 pm.environment.get("key")
清除環境變數 pm.environment.unset("key")
傳送http請求 pm.sendRequest(request,function(err,res){})
示例:
var data = {
"file": {
"title": "sahjf",
"fileB64": res.data.file.fileB64,
"fileType": fileType,
"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": {
"fileB64": "xxx"
獲取返回結果中fileB64的值:
var res = pm.response.json()
res.data.file.fileB64 ---這個為要獲取的值
設定環境變數 pm.environment.set("key","value")
獲取環境變數 pm.environment.get("key")
清除環境變數 pm.environment.unset("key")
傳送http請求 pm.sendRequest(request,function(err,res){})
示例:
var data = {
"file": {
"title": "sahjf",
"fileB64": res.data.file.fileB64,
"fileType": fileType,
"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 ---這個為要獲取的值