赞
踩
目录
1接口
- //后置
- var data = JSON.parse(responseBody);
-
- tests["the search status"] = data.status === 0
- tests["the search msg"] = data.msg === "success"
-
- // console.info(request.data)
-
- pm.environment.set("tripType", JSON.parse(request.data).tripType)
- pm.environment.set("adultNumber",JSON.parse(request.data).adultNumber)
- pm.environment.set("childNumber",JSON.parse(request.data).childNumber)
-
- pm.environment.set("search_shoppingResultList",JSON.stringify([].concat(data.shoppingResultList)))
- pm.environment.set("search_flightList",JSON.stringify([].concat(data.flightList)))
2接口
- //前置
- var routing_data = "HJUK001-2509343459224a2beab70d0|33";
-
-
- /** 根据routing_data 查找航段数据作为请求参数 */
- var search_shoppingResultList = JSON.parse(pm.environment.get("search_shoppingResultList"));
- var search_flightList = JSON.parse(pm.environment.get("search_flightList"));
-
- var routing_search_fromSegment = []
- var routing_search_retSegments = []
-
- for(var i in search_shoppingResultList){
- // 找到指定data
- if(routing_data == search_shoppingResultList[i].data){
- // 定位到指定data的flightRefList
- var rl =search_shoppingResultList[i].flightRefList
- // 找到flightRefList内的段数
- for(var j in rl){
- for(var k in search_flightList){
- // 找到指定data中search_flightList中的flightRefNum对应的数据--去程
- if(rl[j].flightRefNum == search_flightList[k].flightRefNum && rl[j].segmentNo==1){
- // 将rl[j].seatClass的值赋给search_flightList[k].seatClass这个变量
- search_flightList[k].seatClass=rl[j].seatClass;
- // 将search_flightList[k]放到routing_search_fromSegment中,作为请求参数
- routing_search_fromSegment.push(search_flightList[k])
- }else if(rl[j].flightRefNum == search_flightList[k].flightRefNum && rl[j].segmentNo==2){
- search_flightList[k].seatClass=rl[j].seatClass;
- routing_search_retSegments.push(search_flightList[k])
- }
- }
- }
- }
- }
-
-
- pm.environment.set("routing_search_fromSegment",JSON.stringify(routing_search_fromSegment))
- console.log(routing_search_fromSegment)
- pm.environment.set("routing_search_retSegments",JSON.stringify(routing_search_retSegments))
- pm.environment.set("routing_data",routing_data)
-
- //后置
- var data = JSON.parse(responseBody);
-
- tests["the search status"] = data.status === 0
- tests["the search msg"] = data.msg === "成功"
-
- pm.environment.set("sessionId",data.sessionId);
- pm.environment.set("routing_verify_fromSegments",JSON.stringify(data.routing.fromSegments) )
- pm.environment.set("routing_verify_retSegments",JSON.stringify(data.routing.retSegments) )
- pm.environment.set("routing_data", data.routing.data)
other:
- pm.environment.set("order_content",responseBody)
- pm.environment.set("order",responseBody)
- var data = JSON.parse(responseBody);
-
- tests["Status code is 0"] = data.status === 0
- tests["The order msg is 成功"] = data.msg === "成功"
-
- pm.environment.set("pnrCode",data.pnrCode);
-
- console.log(""+data.pnrCode)
更多断言方式可以去看BDD chains(我是看不太懂)
- tests["the search status"] = data.status === 0
- tests["the search msg"] = data.msg === "success"
- //断言响应体内的内容
- pm.test("the search status", function() {
- // var jsonData = pm.response.json();
- // equal or eql
- pm.expect(data.status).to.equal(0)
- });
- pm.test("the search msg", function() {
- pm.expect(data.msg).to.eql("success")
- });
-
-
- pm.test("Response time is less than 200ms", function () {
- pm.expect(pm.response.responseTime).to.be.below(200);
- });
-
-
- // 断言系统响应的
- // pm.test("Status code is 200", function () {
- // pm.response.to.have.status(200);
- // });
- //获取请求数据
- var requestData = request.data
-
-
- //获取响应数据(JSON格式)
- var data = JSON.parse(responseBody);
- //获取请求数据
- var requestData = pm.request.body.raw
-
-
- //获取响应数据(JSON格式)
- var data = pm.response.json()
还是习惯了更新前的...
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。