postman安装使用

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

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

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

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

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

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

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

Postman操作手册:
1、注册:
http://dl2.iteye.com/upload/attachment/0124/8694/8c77bf48-a78e-3f6d-bcd1-38d27675f5cb.png
2、新建Collections:
http://dl2.iteye.com/upload/attachment/0124/8696/0a800ae9-5bc8-332c-a5f8-065d4c2aacf5.png
3、collections下新建子包:
http://dl2.iteye.com/upload/attachment/0124/8698/de682a07-b90a-3569-8628-7f3703fd9feb.png
4、新建http请求并建立归属关系:
http://dl2.iteye.com/upload/attachment/0124/8700/24fe72bc-54df-3594-ac77-8d7bdca14372.png
http://dl2.iteye.com/upload/attachment/0124/8702/252ae395-7bd2-3bd5-bd71-164aff3247e6.png
5、新建不同环境:
http://dl2.iteye.com/upload/attachment/0124/8704/c3d13d39-b0e9-3089-9195-cd96c79caa0e.png
http://dl2.iteye.com/upload/attachment/0124/8706/b396e61d-bfc9-33f6-a7ac-a5d342ac0548.png
http://dl2.iteye.com/upload/attachment/0124/8708/e35f0bba-9c12-3cf1-af26-59f08ab7bd29.png
6、调用链自动化测试:
http://dl2.iteye.com/upload/attachment/0124/8710/e272ecee-718e-30ed-8398-66699b3ee49a.png
http://dl2.iteye.com/upload/attachment/0124/8712/1f4ad696-6636-349f-8507-dbc85d918fe7.png
http://dl2.iteye.com/upload/attachment/0124/8714/c0f8c8d2-bc03-3df9-8255-71431d26aa6b.png
7、调用链测试脚本编写:
http://dl2.iteye.com/upload/attachment/0124/8716/79a513f2-6cb7-3f6a-bb36-b56cccbaf2f8.png
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

猜你喜欢

转载自fangguanhong.iteye.com/blog/2372835
今日推荐