Commit ad51b4a2 authored by Su-Yi's avatar Su-Yi

更新网络框架、钉钉机器人、名片

parent ba57991d
...@@ -21,7 +21,6 @@ public class Home { ...@@ -21,7 +21,6 @@ public class Home {
public void setUp() { public void setUp() {
// 代理人 cookies // 代理人 cookies
network.agentCookies.put("tku","3wSM7Cd4wsesMcuzVhBQVGVupkmB3tT1JHyRbv9sK6ts7f6P67rmuygUqGfPc2Xd9YduvdByMocmpuzNMzKKWd48"); network.agentCookies.put("tku","3wSM7Cd4wsesMcuzVhBQVGVupkmB3tT1JHyRbv9sK6ts7f6P67rmuygUqGfPc2Xd9YduvdByMocmpuzNMzKKWd48");
network.agentCookies.put("acw_tc","76b20ff215756198852864366e248d9e6bfb989ae8f073e81a05f23e6ef703");
network.agentHeaders.put("Content-Type","application/json"); network.agentHeaders.put("Content-Type","application/json");
} }
......
...@@ -21,7 +21,7 @@ public class Pay { ...@@ -21,7 +21,7 @@ public class Pay {
@BeforeClass @BeforeClass
public void setUp() { public void setUp() {
// 代理人 cookies // 代理人 cookies
network.agentCookies.put("tku","T3gM31f18jAXAwJJQPrjuY6xCJQThg3dXxpzkv8X5w3oZZn5yXB41EQad3CuY5A8USk26gxjQvUn7hWekU"); network.agentCookies.put("tku","T3gM31f18j8w3o5y1iEkAGkGxfNgri1yZC1Qix9Y8JawhrzhpZMDhgTzDvhzXSbagbXZxA8AYCbxLPG4SG");
network.agentHeaders.put("Content-Type","application/json"); network.agentHeaders.put("Content-Type","application/json");
} }
...@@ -66,9 +66,8 @@ public class Pay { ...@@ -66,9 +66,8 @@ public class Pay {
payParams.put("oaId","1"); payParams.put("oaId","1");
payParams.put("paySource","2"); payParams.put("paySource","2");
payParams.put("sellerFrom",""); payParams.put("sellerFrom","");
String payJson = JSONObject.toJSONString(payParams);
Response orderAppId = network.PostResponse(payJson,"/kjy/order/create"); Response orderAppId = network.postResponse(payParams,"/kjy/order/create");
String appId = orderAppId.jsonPath().getString("data.appId"); String appId = orderAppId.jsonPath().getString("data.appId");
Assert.assertEquals(appId,"wxcb8c36279dd7dff2","拉起支付:拉起微信支付失败"); //判断返回的微信调起参数中appId是否正确 Assert.assertEquals(appId,"wxcb8c36279dd7dff2","拉起支付:拉起微信支付失败"); //判断返回的微信调起参数中appId是否正确
...@@ -83,8 +82,7 @@ public class Pay { ...@@ -83,8 +82,7 @@ public class Pay {
payParams.put("oaId","1"); payParams.put("oaId","1");
payParams.put("paySource","2"); payParams.put("paySource","2");
payParams.put("sellerFrom",""); payParams.put("sellerFrom","");
String payJson = JSONObject.toJSONString(payParams); Response orderAppId = network.postResponse(payParams,"/kjy/order/create");
Response orderAppId = network.PostResponse(payJson,"/kjy/order/create");
String tradeNo = orderAppId.jsonPath().getString("data.tradeNo"); String tradeNo = orderAppId.jsonPath().getString("data.tradeNo");
...@@ -111,9 +109,11 @@ public class Pay { ...@@ -111,9 +109,11 @@ public class Pay {
int changeVersion = userVersion == 1 ? 2 : 1; // 判断当前开启的版本,如果当前版本是1,则改为2,反之; int changeVersion = userVersion == 1 ? 2 : 1; // 判断当前开启的版本,如果当前版本是1,则改为2,反之;
//切换版本 //切换版本
String changeUserVersionJson = "{\"targetVersion\":" + changeVersion + "}"; Map<String, Object> versionParams = new HashMap<String, Object>();
Response resultResponse = network.PostResponse(changeUserVersionJson,"/kjy/mp/version/exchange"); versionParams.put("targetVersion",changeVersion);
Response resultResponse = network.postResponse(versionParams,"/kjy/mp/version/exchange");
String result = resultResponse.jsonPath().getString("desc"); String result = resultResponse.jsonPath().getString("desc");
Assert.assertEquals(result,"OK","会员类型切换:切换失败"); //判断返回的微信调起参数中appId是否正确 Assert.assertEquals(result,"OK","会员类型切换:切换失败"); //判断返回的微信调起参数中appId是否正确
...@@ -130,7 +130,7 @@ public class Pay { ...@@ -130,7 +130,7 @@ public class Pay {
// 绑定一个上级为保险版的会员,scId和inviterSid可以在用户分享的链接里拿到 // 绑定一个上级为保险版的会员,scId和inviterSid可以在用户分享的链接里拿到
Map<String, Object> distributeParams = new HashMap<String, Object>(); Map<String, Object> distributeParams = new HashMap<String, Object>();
distributeParams.put("scId","Kj21OTk0MTU"); //文章ID: 文章转化访客时,传此参数 distributeParams.put("scId","Kj21OTk0MTU"); //文章ID: 文章转化访客时,传此参数
distributeParams.put("inviterSid","Kj21MTQ4OTU"); //销售ID: 会员邀请好友付费时,传此参数 distributeParams.put("inviterSid","Kj21MTQ4OTU"); //销售ID:1861加密后 会员邀请好友付费时,传此参数
distributeParams.put("fromStr",6); //文章来源: 6文章访客转化 1会员邀请 distributeParams.put("fromStr",6); //文章来源: 6文章访客转化 1会员邀请
distributeParams.put("accessSource",12); //支付来源:客集集 distributeParams.put("accessSource",12); //支付来源:客集集
Response distributeResponse = network.getResponse(distributeParams,"/kjy/sp/visitorPayment/distribute"); Response distributeResponse = network.getResponse(distributeParams,"/kjy/sp/visitorPayment/distribute");
...@@ -171,9 +171,8 @@ public class Pay { ...@@ -171,9 +171,8 @@ public class Pay {
payParams.put("oaId","1"); payParams.put("oaId","1");
payParams.put("paySource","2"); payParams.put("paySource","2");
payParams.put("sellerFrom",""); payParams.put("sellerFrom","");
String payJson = JSONObject.toJSONString(payParams);
Response orderAppId = network.PostResponse(payJson,"/kjy/order/create"); Response orderAppId = network.postResponse(payParams,"/kjy/order/create");
String appId = orderAppId.jsonPath().getString("data.appId"); String appId = orderAppId.jsonPath().getString("data.appId");
Assert.assertEquals(appId,"wxcb8c36279dd7dff2","拉起支付:拉起微信支付失败"); //判断返回的微信调起参数中appId是否正确 Assert.assertEquals(appId,"wxcb8c36279dd7dff2","拉起支付:拉起微信支付失败"); //判断返回的微信调起参数中appId是否正确
} }
...@@ -199,8 +198,7 @@ public class Pay { ...@@ -199,8 +198,7 @@ public class Pay {
payParams.put("oaId","1"); payParams.put("oaId","1");
payParams.put("paySource","2"); payParams.put("paySource","2");
payParams.put("sellerFrom",""); payParams.put("sellerFrom","");
String payJson = JSONObject.toJSONString(payParams); Response orderAppId = network.postResponse(payParams,"/kjy/order/create");
Response orderAppId = network.PostResponse(payJson,"/kjy/order/create");
String tradeNo = orderAppId.jsonPath().getString("data.tradeNo"); String tradeNo = orderAppId.jsonPath().getString("data.tradeNo");
...@@ -223,8 +221,10 @@ public class Pay { ...@@ -223,8 +221,10 @@ public class Pay {
int changeVersion = userVersion == 1 ? 2 : 1; // 判断当前开启的版本,如果当前版本是1,则改为2,反之; int changeVersion = userVersion == 1 ? 2 : 1; // 判断当前开启的版本,如果当前版本是1,则改为2,反之;
//切换版本 //切换版本
String changeUserVersionJson = "{\"targetVersion\":" + changeVersion + "}"; //切换版本
Response resultResponse = network.PostResponse(changeUserVersionJson,"/kjy/mp/version/exchange"); Map<String, Object> versionParams = new HashMap<String, Object>();
versionParams.put("targetVersion",changeVersion);
Response resultResponse = network.postResponse(versionParams,"/kjy/mp/version/exchange");
String result = resultResponse.jsonPath().getString("desc"); String result = resultResponse.jsonPath().getString("desc");
Assert.assertEquals(result,"OK","会员类型切换:切换失败"); //判断返回的微信调起参数中appId是否正确 Assert.assertEquals(result,"OK","会员类型切换:切换失败"); //判断返回的微信调起参数中appId是否正确
......
...@@ -36,7 +36,7 @@ public class NetworkOperation { ...@@ -36,7 +36,7 @@ public class NetworkOperation {
private static String host = "https://kjj.m.duibatest.com.cn"; //测试环境 private static String host = "https://kjj.m.duibatest.com.cn"; //测试环境
//钉钉机器人域名 //钉钉机器人域名
private static String dingtalkPath = "https://oapi.dingtalk.com/robot/send?access_token=f63c9cb36e89dd68e9af82d926933b3afc6544e57b23a3a55ed5b3b772d5e8d2"; private static String dingtalkPath = "https://oapi.dingtalk.com/robot/send?access_token=e4b7d997fb9f90b17672dcdb9c9922d52c59f741b82081a368f4d3c305c1afcd";
// get 不带参请求 // get 不带参请求
public Response getResponse(String path) { public Response getResponse(String path) {
...@@ -56,7 +56,7 @@ public class NetworkOperation { ...@@ -56,7 +56,7 @@ public class NetworkOperation {
} }
// post 不帶参请求 // post 不帶参请求
public Response PostResponse(String path) { public Response postResponse(String path) {
return given() return given()
.cookies(agentCookies) .cookies(agentCookies)
.headers(agentHeaders) .headers(agentHeaders)
...@@ -64,7 +64,8 @@ public class NetworkOperation { ...@@ -64,7 +64,8 @@ public class NetworkOperation {
} }
// post 带参请求 // post 带参请求
public Response PostResponse(String jsonStr, String path) { public Response postResponse(Map<String, Object> params, String path) {
String jsonStr = JSONObject.toJSONString(params);
return given() return given()
.cookies(agentCookies) .cookies(agentCookies)
.headers(agentHeaders) .headers(agentHeaders)
...@@ -74,7 +75,8 @@ public class NetworkOperation { ...@@ -74,7 +75,8 @@ public class NetworkOperation {
} }
// post 带参请求 // post 带参请求
public Response dingTalkRobot(String jsonStr) { public Response dingTalkRobot(Map<String, Object> params) {
String jsonStr = JSONObject.toJSONString(params);
dingTalkHeaders.put("Content-Type","application/json;charset=utf-8"); dingTalkHeaders.put("Content-Type","application/json;charset=utf-8");
return given() return given()
......
...@@ -2,17 +2,28 @@ package com.kjj.qa.utils; ...@@ -2,17 +2,28 @@ package com.kjj.qa.utils;
import com.kjj.qa.services.NetworkOperation; import com.kjj.qa.services.NetworkOperation;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
public class DingTalkUtil { public class DingTalkUtil {
//通过钉钉机器人发送消息到钉钉群中 //通过钉钉机器人发送消息到钉钉群中
public static void sendVal(String context)throws Exception{ public static void sendVal(String context)throws Exception{
context = context+"报告地址:http://10.254.187.25/view/kjj_test/job/kejiji_interface/ws/test-output/report.html"; //测试结果
String entityString ="{'msgtype': 'text', 'text': {'content': '【测试结果】\n"+context+"'}}"; context = "【测试结果】\n"
+ context
+ "报告地址: http://10.254.187.25/view/kjj_test/job/kejiji_interface/ws/test-output/report.html";
System.out.println(entityString); Map<String, Object> contentParams = new HashMap<String, Object>();
contentParams.put("content",context);
//钉钉机器人消息体
Map<String, Object> params = new HashMap<String, Object>();
params.put("msgtype","text");
params.put("text",contentParams);
// System.out.println(params);
NetworkOperation network = new NetworkOperation(); NetworkOperation network = new NetworkOperation();
network.dingTalkRobot(entityString); //发起请求 network.dingTalkRobot(params); //发起dingding机器人通知
} }
......
package com.kjj.qa.utils; package com.kjj.qa.utils;
import com.kjj.qa.services.NetworkOperation;
public final class KjyUtil { public final class KjyUtil {
} }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="客集集-测试结果" verbose="1" thread-count="3"> <suite name="客集集-测试结果" verbose="1" thread-count="3">
<test preserve-order="true" name="首页" > <!-- <test preserve-order="true" name="首页" >-->
<!-- <classes>-->
<!-- <class name="com.kjj.qa.cases.Home"/>-->
<!-- </classes>-->
<!-- </test>-->
<test preserve-order="true" name="支付" >
<classes> <classes>
<class name="com.kjj.qa.cases.Home"/> <class name="com.kjj.qa.cases.Pay"/>
</classes> </classes>
</test> </test>
<test preserve-order="true" name="支付" > <test preserve-order="true" name="名片" >
<classes> <classes>
<class name="com.kjj.qa.cases.Pay"/> <class name="com.kjj.qa.cases.SellerCard"/>
</classes> </classes>
</test> </test>
<!-- <test preserve-order="true" name="名片" >-->
<!-- <classes>-->
<!-- <class name="com.kjj.qa.cases.SellerCard"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- 监听器--> <!-- 监听器-->
<listeners> <listeners>
<listener class-name="com.kjj.qa.config.ExtentTestNGIReporterListener"/> <listener class-name="com.kjj.qa.config.ExtentTestNGIReporterListener"/>
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment