Postman 基本操做学习

clip_image004_thumb

History

全部使用postman发送的request都会保存在这里。点击以后会在当前Tab打开。java

参考: Requests Historypython

clip_image005_thumb

Environments

这里用来设定当前request 发送时使用的环境,好比这里能够选择“Cooper-Remote.template”或者“header_encode_style”或者“test_demo”,还能够选择“No Environment”,表示当前request不使用任何环境。shell

环境其实就是多组 key-value 。环境能够被下载保存为JSON文件。也能够导入环境,好比CSV或者JSON文件。浏览器

参考:Setting up an environment with variablescookie

Using environments to switch contextside

clip_image007_thumb

这里的环境其实就是一组key-value的集合。好比选择“Cooper-Remote.template”的话,URL以及Test等等均可以经过{{url}}以及{{items}}来直接使用这些变量。oop

clip_image009_thumb

Global variables

点击眼形图标,能够看到当前可使用的全部变量:包括选择的Environment的以及其余request添加到Globals里面的变量。post

Environment和 Global的区别在于: 整个postman能够保存多个Environment,可是只会存在一组Global。 保存在Global里的key-value能够被全部的request使用,可是一个request只能选择一个Environment。测试

参考:Setting up an environment with variablesui

clip_image010_thumb

Request

image_thumb3[1]

method

参考: Sending Requests Method

比较常见的有 GET、POST、PUT,还有一些不常见的好比 PATCH、DELETE等。

URL & Params

参考: Sending Requests URL

URL能够输入request的地址,Params是对应的URL的参数。在Params中输入参数,会自动同步到URL。同理,URL里面输入带有参数的地址,也会自动同步参数到Params。

image_thumb4[1]

Send

发送当前请求。”Send and Download“ 在发送请求以后,会自动下载该请求的response。

image_thumb5

Save

能够直接保存request。也能够选择“Save as”。

Save as 能够保存 请求的名字以及简单的描述。还能够决定要不要把请求保存到Collection里面去。

参考: Getting started with Collections Saving requests inside a collection

image_thumb6

image_thumb7

Authorization

若是访问的服务须要验证,这里能够设置验证方式+填写验证所需的信息,好比用户名密码。

参考: Authentication helpers

image_thumb8[1]

Headers

参考: Sending Requests Headers

定义HTTP Header。

image_thumb9

Body

参考: Sending Requests Request body

设置请求的body。有四种方式进行设置: form-data、 urlencoded、raw 以及 binary。

GET是不能够设置Body的,POST请求能够。

image_thumb

Pre-request Script

参考:Pre Request Scripts

请求前须要执行的脚本能够放置在这里。主要进行一些环境以及全局变量的设置。

image_thumb10

Tests

参考:Writing Tests

           Testing examples

这里写测试用例,进行一些判断等等。

下面新建了两个测试用例,名字分别是”Status code is 200“ 、”Status code name has string“。

“responseCode.code === 200” 返回 True 或者 False,进而判断 ”Status code is 200“ 这个用例是Pass仍是Fail。

image_thumb12

Generate Code

这里能够将request转化为各类语言的代码。好比python、java、shell、HTTP等。

image_thumb14

Response

Body

参考: Understanding and working with responses Viewing responses

这里能够查看返回的应答的body部分。

有三种查看方式: Pretty、 Raw、Preview。

Pretty会根据选择的类型对Body进行高亮显示,同时能够选择要不要自动换行,方便阅读。

Raw不会进行任何高亮显示。

Preview显示的是Body部分的预览效果。

image_thumb1

Cookies

参考: Understanding and working with responses Cookies

展现浏览器的cookies。

Headers

参考: Understanding and working with responses Headers

以key-value对的方式展现返回的header部分。鼠标停留在key上,会显示该key的说明(根据HTTP文档)。

image_thumb3

Tests

展现测试结果。

image_thumb4

Status

展现返回的状态。鼠标方式在状态上,好比“200 OK”上,会显示该状态对应的说明。

image_thumb5[1]

Collections

介绍

我的感受一个Collection就像是一个测试Project。而后Collection里面能够放置文件夹,也能够直接放置request,放置文件夹就像一个 testsuite。 文件夹里面能够放置多个request,一个request能够写1个或者多个test。

参考: Getting started with Collections

image_thumb6[1]

Share Collection

Collection能够share给组员,也能够download为JSON文件而后发送给组员进行导入使用。

参考:Sharing Collections with your team

image_thumb7[1]

Run Collection

Collection能够直接run。

参考: Running a collection

1) Previous Runs 展现过去run的collection,点击能够在Statistics面板显示具体的结果。

OVERVIEW:该Collection 该轮测试PASS/FAIL数目整体概况。

Previous Runs:该Collection过去run的OVERVIEW,用来进行对比。

REQUESTS:该Collection 该轮测试的详细状况。

image_thumb10[1]

2) CURRENT RUN 能够设置当前想要run的 collection,还能够对Environment、Iteration、Delay、Data File 进行设置。

Environment:选择跑该Collection的 Environment。

Iteration: 设置该轮测试跑几轮。

Delay: 。。。。。。。

Date: 能够选择加载一个 CSV/JSON的数据文件

image_thumb8

3) RESULTS

点击“Start Test”就能够开始跑Collection啦。

实时结果会在 RESULTS里面显示出来。

image_thumb9[1]

相关文章
相关标签/搜索