1.新建“New Collections”
单击““New Collections”菜单(如图1),在弹出的对话框中(如图2),编写基本信息,单击“create”,创建成功
图1
图2
2.创建请求接口
根据遍历“id”调用用户信息
1) 单击已经创建好的“遍历查询所有用户信息”文件夹,右击“Add requests”或者直接单击如图3“Add request”,在弹出的“SAVE Requert”会话框中如图4,输入接口名,(这个接口名有点特殊,通常我们会用getuserInfo来命名,但这里可能是Postman的开发还没完善的原因,再或者说可能因为我本人还没发现更好的办法吧,我这里的命名写的是请求地址,系统报url不能为空。也可以先随便命名,后面创建好接口再复制接口地址重新给接口命名)最后单击“save to”
图3
图4
2)使用GET 方式,调用用户信息接口
openid用变量{{id}}
图5
3. 循环调用
1)单击“runner”,在弹出的runner对话框中,选择刚创建好的Collections(遍历查询用户信息)
图6
2)配置数据
图7
lterations:循环次数,默认显示选择json文件数组的长度
data:是微信用户列表接口返回值进行加工处理的保存在本地的json文件,格式如下:
[ {"id":"ow46Fs1sAn_vLaY9UaDaO_un4"}, {"id":"ow46Fs3__WPZjk7plNj7NY3qI"}, {"id":"ow46Fs8NkQtQAVoEvwhGKVmjU"}, {"id":"ow46Fs2RqMBmXb4j8z_ofmxf4"}, {"id":"ow46Fs3NnZ5L1emxrROYaYWj4"}, {"id":"ow46Fs6OZvWn1BfJKWaIAPZ5E"}, {"id":"ow46Fs-4oFDPouGPYd9njhZrM"}, {"id":"ow46Fs7NObjpJEHw2KdU95B1o"}, {"id":"ow46Fsx5JdDxeNUL8xRaVSDkk"}, {"id":"ow46Fs61Sa2P6qDAhGFcAh048"}, {"id":"ow46Fs_m145nsyHjglVAASG_8"}, {"id":"ow46Fs3bqGNqyInZd4fhwxRgc"}, {"id":"ow46Fs-JZHmLgTkY9HP21b1-Q"}, {"id":"ow46Fs4gknSZCDMGeDz7n3oFQ"}, {"id":"ow46FszjPGULI82drFLTAvR0E"}, {"id":"ow46Fs0HLSdS1nWVXLmGFaAV0"}, {"id":"ow46Fs6SxcXTwBXfqq3btKPqw"}, {"id":"ow46Fsxogpja-q0DFWekKJc0Y"}, {"id":"ow46Fs7Cuh_I3i-WgGpYkK9XU"}, {"id":"ow46Fs8m2uNJEL_HEtbkktV-A"}, {"id":"ow46Fs7Gx5Bk3-8OmDzDqGovM"}, {"id":"ow46Fsx84dFjJBbjnXCNpzJBw"}, {"id":"ow46FsyxMRXmVhsO5bJWcxQGI"}, {"id":"ow46Fs0MzSuWGhteH2gTY4yaE"}, {"id":"ow46Fs3b7gyyRxw_KGeuU89F4"}, {"id":"ow46Fs8stOPjnhbnpOa-ykgwY"}, {"id":"ow46Fs0wwq2Pt2eH2N1uzv2PI"}, {"id":"ow46FsweLucWIK1gD_Bu2wdWU"}, {"id":"ow46Fs224JIId8DZMdI07hU0E"}, {"id":"ow46Fs6hKn-hdh9LxdBEJ9fcU"}, {"id":"ow46Fs4C5hlVW3Rny2xECYskY"}, {"id":"ow46Fs1hcRzkHPQGwBZb3v9h4"}, {"id":"ow46Fs5JJEIwvV20LIdPjgHdE"}, {"id":"ow46Fs4VvH1YMKF5QkcyplaPo"}, {"id":"ow46FswFOaLSQA1AcqNJUJ22Q"}, {"id":"ow46Fs5OLkSvqCmPJ7W2oUUwI"}, {"id":"ow46Fs5SPxghczmXBc9lXqbe4"}, {"id":"ow46Fs_xD_0I-HfhioYCqtT2o"}, {"id":"ow46Fs_RLhUJakd_TgeLEw-kM"}, {"id":"ow46FsxO6IZyvmZ2dqqu8T6dM"}, {"id":"ow46Fs6n59uTMnOTQDHqN0hNs"}, {"id":"ow46Fs8XTeJ37xYK0HUJq02Ww"}, {"id":"ow46FswP8KuMBgILr9JlOZ_1o"} ]
3)单击"run",就循环调用成功了
图8
4.客户有个需求根据需要给用户中日文分类打标签
在接口的Tests设置断言如图9,结果为passed 为日文,否则显示中文,
tests["result"] = JSON.parse(responseBody).language === 'ja';
图9