postman 的内置脚本和说明大家收藏吧备着使用

1. 清除一个全局变量
     Clear a global variable
    对应脚本:
    postman.clearGlobalVariable("variable_key");
    参数:需要清除的变量的key

2.清除一个环境变量
    Clear an environment variable
    对应脚本:
    postman.clearEnvironmentVariable("variable_key");
    参数:需要清除的环境变量的key

3.response包含内容
    Response body:Contains string
    对应脚本:
    tests["Body matches string"] =responseBody.has("string_you_want_to_search");
    参数:预期内容

4.将xml格式的response转换成son格式
    Response body:Convert XML body to a JSON Object
    对应脚本:
    var jsonObject = xml2Json(responseBody);
    参数:(默认不需要设置参数,为接口的response)需要转换的xml

5.response等于预期内容
    Response body:Is equal to a string
    对应脚本:
    tests["Body is correct"] = responseBody === "response_body_string";
    参数:预期response

6.json解析key的值进行校验
    Response body:JSON value check
    对应脚本:
    te
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值