postman安装使用

postman下载地址:
[url]https://www.getpostman.com/[/url]

使用讲解:
[url]http://www.cnblogs.com/s380774061/p/4624326.html[/url]
[url]http://www.cnblogs.com/s380774061/p/4822722.html[/url]
[url]http://www.cnblogs.com/s380774061/p/5037591.html[/url]

[url]http://blog.csdn.net/u013613428/article/details/51557804[/url]
[url]http://blog.csdn.net/u013613428/article/details/51557914[/url]
[url]http://blog.csdn.net/u013613428/article/details/51577209[/url]

postman自动化测试:
[url]https://segmentfault.com/a/1190000005055899[/url]
[url]http://blog.csdn.net/galen2016/article/details/66969557[/url]
[url]http://www.cnblogs.com/sunshine-sky66/p/6369963.html[/url]
[url]http://jingyan.baidu.com/article/5552ef47f279ba518ffbc9c3.html[/url]
[url]http://blog.csdn.net/liuchunming033/article/details/51438022[/url]
[url]https://testerhome.com/topics/6555[/url]
[url]http://www.jianshu.com/p/87da60601aa6?mType=Group[/url]
[url]http://www.cnblogs.com/yy-cxd/p/5818827.html[/url]
[url]http://blog.csdn.net/water_0815/article/details/53346190[/url]

DHC相关介绍:
[url]http://blog.csdn.net/u014079773/article/details/52675389[/url]

Chrome内嵌DHC插件方法:
更多工具-->扩展程序-->加载已解压的扩展程序(将DHC那个压缩包解压到一个地方,然后在这里选择解压的那个文件夹即可,之后就将该插件导入到chrome里了)

想要安装最新版本的DHC(Restlet)还是fanqiang直接在chrome应用商店里下载吧,那个比较快!

Postman操作手册:
1、注册:
[url]http://dl2.iteye.com/upload/attachment/0124/8694/8c77bf48-a78e-3f6d-bcd1-38d27675f5cb.png[/url]
2、新建Collections:
[url]http://dl2.iteye.com/upload/attachment/0124/8696/0a800ae9-5bc8-332c-a5f8-065d4c2aacf5.png[/url]
3、collections下新建子包:
[url]http://dl2.iteye.com/upload/attachment/0124/8698/de682a07-b90a-3569-8628-7f3703fd9feb.png[/url]
4、新建http请求并建立归属关系:
[url]http://dl2.iteye.com/upload/attachment/0124/8700/24fe72bc-54df-3594-ac77-8d7bdca14372.png[/url]
[url]http://dl2.iteye.com/upload/attachment/0124/8702/252ae395-7bd2-3bd5-bd71-164aff3247e6.png[/url]
5、新建不同环境:
[url]http://dl2.iteye.com/upload/attachment/0124/8704/c3d13d39-b0e9-3089-9195-cd96c79caa0e.png[/url]
[url]http://dl2.iteye.com/upload/attachment/0124/8706/b396e61d-bfc9-33f6-a7ac-a5d342ac0548.png[/url]
[url]http://dl2.iteye.com/upload/attachment/0124/8708/e35f0bba-9c12-3cf1-af26-59f08ab7bd29.png[/url]
6、调用链自动化测试:
[url]http://dl2.iteye.com/upload/attachment/0124/8710/e272ecee-718e-30ed-8398-66699b3ee49a.png[/url]
[url]http://dl2.iteye.com/upload/attachment/0124/8712/1f4ad696-6636-349f-8507-dbc85d918fe7.png[/url]
[url]http://dl2.iteye.com/upload/attachment/0124/8714/c0f8c8d2-bc03-3df9-8255-71431d26aa6b.png[/url]
7、调用链测试脚本编写:
[url]http://dl2.iteye.com/upload/attachment/0124/8716/79a513f2-6cb7-3f6a-bb36-b56cccbaf2f8.png[/url]
8、测试脚本常用语法讲解:
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");
参数:预期内容
改版:tests["包含test关键字"] = jsonData.data.username.has(“test”);
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
对应脚本:
tests["Args key contains argument passed as url parameter"] = 'test' in responseJSON.args
参数:test替换被测的值,args替换被测的key
7).检查response的header信息是否有被测字段
Response headers:Content-Type header check
对应脚本:
tests["Content-Type is present"] = postman.getResponseHeader("Content-Type");
参数:预期header
8).响应时间判断
Response time is less than 200ms
对应脚本:
tests["Response time is less than 200ms"] = responseTime < 200;
参数:响应时间
9).设置全局变量
Set an global variable
对应脚本:
postman.setGlobalVariable("variable_key", "variable_value");
参数:全局变量的键值
10).设置环境变量
Set an environment variable
对应脚本:
postman.setEnvironmentVariable("variable_key", "variable_value");
参数:环境变量的键值
11).判断状态码
Status code:Code is 200
对应脚本:
tests["Status code is 200"] = responseCode.code != 400;
tests["Status code is 200"] = responseCode.code === 200;
参数:状态码
12).检查code name 是否包含内容
Status code:Code name has string
对应脚本:
tests["Status code name has string"] = responseCode.name.has("Created");
参数:预期code name包含字符串
13).成功的post请求
Status code:Successful POST request
对应脚本:
tests["Successful POST request"] = responseCode.code === 201 || responseCode.code === 202;

9、全局变量和环境变量的区别:
全局变量(Globals)的用法与环境变量类似,只是对于 Postman 来说,Globals 仅有一组,而环境变量可以有多组。创建全局变量也要先打开环境变量的管理窗口。
10、使用示例:
见Postman
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值