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

新增常量类、首页case

parent 7e774f54
package com.kjj.qa.cases;
import static com.kjj.qa.config.BasicConfig.*;
import com.kjj.qa.utils.NetworkUtil;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class Article {
NetworkUtil network = NetworkUtil.getInstance();
String scid = "";
String sid = "";
@BeforeClass
public void setUp() {
}
//文章内容页
@Test(description="文章内容页",priority = 1)
public void 文章内容页() throws IOException{
//根据ContentId获取Scid
Map<String, Object> params = new HashMap<String, Object>();
params.put("contentId",ARTICLE_CONTENTID);
Response response = network.getResponse(params, GETSCID);
scid = response.jsonPath().getString("data");
Assert.assertNotNull(scid,network.message(params, GETSCID,"获取scId失败"));
Map<String, Object> infoParams = new HashMap<String, Object>();
infoParams.put("scid",scid);
response = network.getResponse(infoParams,ARTICLE_H5INFO);
String id = response.jsonPath().getString("data.id");
Assert.assertEquals(ARTICLE_CONTENTID,id, network.message(infoParams,ARTICLE_H5INFO,"获取文章内容页失败"));
}
//名片是否展示
@Test(description="名片是否展示",priority = 2)
public void 名片是否展示() throws IOException {
//关闭名片展示
Map<String, Object> sellerCardParams = new HashMap<String, Object>();
sellerCardParams.put("configKey","card_show_on_top");//素材头部名片
sellerCardParams.put("configValue",false);
Response response = network.postResponse(sellerCardParams,SELLERCONFIG_EDITCONFIG);
boolean isChanged = response.jsonPath().getBoolean("data");
Assert.assertTrue(isChanged,network.message(sellerCardParams,SELLERCONFIG_EDITCONFIG,"关闭素材头部名片失败"));
sellerCardParams.put("configKey","card_show_on_bottom");//素材尾部名片
sellerCardParams.put("configValue",false);
response = network.postResponse(sellerCardParams,SELLERCONFIG_EDITCONFIG);
isChanged = response.jsonPath().getBoolean("data");
Assert.assertTrue(isChanged,network.message(sellerCardParams,SELLERCONFIG_EDITCONFIG,"关闭素材底部名片失败"));
//检查文章内名片展示
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
response = network.getResponse(params,SELLERCARD_GETSELLERCARDCONFIG);
int openCount = response.jsonPath().getInt("data.findAll {it.val == true}.size()");
Assert.assertEquals(openCount,0,network.message(params,SELLERCARD_GETSELLERCARDCONFIG,"名片关闭状态与设置中心不一致"));
//开启名片展示
sellerCardParams.put("configKey","card_show_on_top");//素材尾部名片
sellerCardParams.put("configValue",true);
response = network.postResponse(sellerCardParams,SELLERCONFIG_EDITCONFIG);
sellerCardParams.put("configKey","card_show_on_bottom");//素材尾部名片
sellerCardParams.put("configValue",true);
response = network.postResponse(sellerCardParams,SELLERCONFIG_EDITCONFIG);
//再次检查文章内名片展示
response = network.getResponse(params,SELLERCARD_GETSELLERCARDCONFIG);
openCount = response.jsonPath().getInt("data.findAll {it.val == true}.size()");
Assert.assertEquals(openCount,2,network.message(params,SELLERCARD_GETSELLERCARDCONFIG,"名片开启状态与设置中心不一致"));
//名片样式
Map<String, Object> styleParams = new HashMap<String, Object>();
styleParams.put("id",scid);
response = network.getResponse(styleParams,SELLERCARD_GETSELLERCARDSTYLE);
String backgroundColor = response.jsonPath().getString("data.find {it.code == 'card_background_color'}.val");
Assert.assertEquals(backgroundColor,"1",network.message(styleParams,SELLERCARD_GETSELLERCARDSTYLE,"名片-背景色样式不对"));
}
// 头部名片
@Test(description="头部名片详情",priority = 3)
public void 头部名片详情() throws IOException {
//获取加密的销售ID
Response response = network.getResponse(USER_INFO);
sid = response.jsonPath().getString("data.encodeSellerId");
String sellerName = response.jsonPath().getString("data.sellerName");
//获取名片的姓名、公司等
Map<String, Object> params = new HashMap<String, Object>();
params.put("sid",sid);
params.put("t", System.currentTimeMillis());
response = network.getResponse(params,SELLERCARD_TOPOFCONTENT);
String scId = response.jsonPath().getString("data.scid");
String name = response.jsonPath().getString("data.sellerName");
Assert.assertEquals(name,sellerName,"头部名片信息显示有误");
//获取名片的点赞
Map<String, Object> likeParams = new HashMap<String, Object>();
likeParams.put("scId",scId);
response = network.getResponse(likeParams,HASALREADYLIKE);
int favourTimes = response.jsonPath().getInt("data.favourTimes");
Assert.assertEquals(favourTimes,0,"头部名片点赞数量显示有误");
}
// 底部名片
@Test(description="底部名片详情",priority = 4)
public void 底部名片详情() throws IOException {
//获取加密的销售ID
Response response = network.getResponse(USER_INFO);
sid = response.jsonPath().getString("data.encodeSellerId");
String sellerName = response.jsonPath().getString("data.sellerName");
//获取名片的姓名、公司等
Map<String, Object> params = new HashMap<String, Object>();
params.put("sid",sid);
params.put("t", System.currentTimeMillis());
response = network.getResponse(params,SELLERCARD_TOPOFCONTENT);
String name = response.jsonPath().getString("data.sellerName");
Assert.assertEquals(name, sellerName,"底部名片信息显示有误");
}
// 是否爆款素材
@Test(description="文章类型判断",priority = 5)
public void 文章类型判断() throws IOException {
//获得素材类型 种草、发圈
Map<String, Object> params = new HashMap<String, Object>();
params.put("id",ARTICLE_CONTENTID);
Response response = network.getResponse(params,ARTICLE_GETTAGTYPESBYCONTENTID);
boolean isContains = response.jsonPath().getBoolean("data.contains('grass_content')");
Assert.assertTrue(isContains,"类型判断错误-类型应该存在种草素材");
//获得爆款素材详情
Map<String, Object> infoParams = new HashMap<String, Object>();
infoParams.put("contentId",ARTICLE_CONTENTID);
response = network.getResponse(infoParams,ARTICLE_GETEXPINFO);
String tags = response.jsonPath().getString("data.tags");
Assert.assertEquals(tags,"放到沙发上",network.message(infoParams,ARTICLE_GETEXPINFO,"文章内标签-获取失败"));
}
//
}
......@@ -21,99 +21,5 @@ public class Home {
}
@Test (description = "JSSDK",priority = 1) //priorty 方法执行优先级
public void JSSDK() throws IOException {
//参数
Map<String, Object> params = new HashMap<String, Object>();
params.put("url","https://kjj.m.duiba.com.cn/#/?access_source=31");
params.put("retry","false");
Response response = network.getResponse(params,"/kjy/mp/seller/getOaJssdk");
boolean result = response.jsonPath().getBoolean("success");
Assert.assertEquals(result,true,"获取jssdk失败");
}
// @Test (description = "早中晚日报列表",priority = 2)
// public void 早中晚日报列表() throws IOException {
// Response response = network.getResponse("/kjy/mp/content/getInitDailyList");
// int status = response.jsonPath().get("data[0].status");
// Assert.assertEquals(status,2,"获取早中晚日报列表信息失败");
// }
//
// @Test (description = "精准素材库",priority = 3)
// public void 精准素材库() throws IOException {
// Response response = network.getResponse("/kjy/mp/accurate/usrDetail");
// int result = response.jsonPath().get("data.companyId");
// Assert.assertEquals(result,5,"获取精准素材成功");
//// Reporter.log("用例执行失败:服务器错误!");
// }
//
// @Test (description = "今日访问",priority = 4)
// public void 今日访问() throws IOException {
// //获取旧的今日访问数量
// Response response = network.getResponse("/kjy/mp/seller/todayVisit");
// int oldTodayCount = response.jsonPath().get("data.todayCount");
//
// //访问名片 具体啥接口得问开发
// Map<String, Object> params = new HashMap<String, Object>();
// params.put("contentId",79040);
// params.put("scId","7703312855");
// params.put("comefrom",1);
// params.put("fromUserId","2477770");
// Response vistorRes = network.visitorBehavior(params,"/kjy/mp/sellerCard/visit");
//
// //获取新的今日访问数量
// response = network.getResponse("/kjy/mp/seller/todayVisit");
// int newTodayCOunt = response.jsonPath().get("data.todayCount");
//
// Assert.assertEquals(oldTodayCount + 1,newTodayCOunt,"今日访问量统计有误");
// }
//
// @Test (description = "分类列表",priority = 5)
// public void 分类列表() throws IOException {
// Response response = network.getResponse("/kjy/mp/classify/list");
// String classifyName = response.jsonPath().get("data.list[0].classifyName");
// Assert.assertEquals(classifyName ,"推荐","获取列表信息失败");
//
// // 检验是否有公司专区
// }
//
// @Test (description = "推荐分类下的内容列表",priority = 6)
// //首頁-信息
// public void 推荐分类下的内容列表() throws IOException {
// //穿的分页参数
// Map<String, Object> params = new HashMap<String, Object>();
// params.put("classfiyId","1");
// params.put("pageIndex","1");
// params.put("pageSize","10");
//
// Response response = network.getResponse(params,"/kjy/mp/classify/contentList");
// int pageSize = response.jsonPath().get("data.pageSize");
// Assert.assertEquals(pageSize,10,"获取分类下的内容列表失败");
// }
//
// @Test (description = "用户信息",priority = 7)
// public void 用户信息() throws IOException {
// //获取旧的今日访问数量
// Response response = network.getResponse("/kjy/mp/user/info");
// String wxName = response.jsonPath().get("data.wxName");
// Assert.assertEquals(wxName ,"小葡萄","获取用户信息失败");
// }
//
// @Test (description = "销售员公司资料总数",priority = 8)
// //首頁-信息
// public void 销售员公司资料总数() throws IOException {
// Response response = network.getResponse("/kjy/mp/companyDocument/count");
// boolean result = response.jsonPath().getBoolean("success");
// Assert.assertEquals(result, true, "获取销售员公司资料总数失败");
//// Reporter.log("用例执行失败:服务器错误!");
// }
//
// @AfterSuite
// public void testSuite() throws IOException {
//
// }
}
This diff is collapsed.
This diff is collapsed.
package com.kjj.qa.config;
public class BasicConfig {
public static int apiCount; //接口数量统计
// *************** 客集集域名 ***************
public static final String HOST = "https://kjj.m.duibatest.com.cn"; // "https://kjj.m.duiba.com.cn";
// *************** TKU ***************
public static final String AGENT_TKU = "T3gM31f18jAWdsgwEXerFu4dYyoQcnhivxyRx2wA2KmB989G6CTqzhTceYm81EiUQqHQZ5r14ZefWuDZrK";
public static final String VISITOR_TKU = "T3gM31f18jAWudwfTW6o9zs27w5xMjdhLHsKVP3cHo9Aj7Q4Fg7WyEkqXiKWWdLHka1jjGseU7JpgC2UaU";
// *************** 钉钉机器人 ***************
// 线上-告警群
// public static final String DINGTALKPATH = "https://oapi.dingtalk.com/robot/send?access_token=f63c9cb36e89dd68e9af82d926933b3afc6544e57b23a3a55ed5b3b772d5e8d2";
// 测试
public static final String DINGTALKPATH = "https://oapi.dingtalk.com/robot/send?access_token=e4b7d997fb9f90b17672dcdb9c9922d52c59f741b82081a368f4d3c305c1afcd";;
// *************** 素材ID ***************
public static final String ARTICLE_CONTENTID = "Kj21NjQ5NDM";
public static final String ANIMATION_CONTENTID = "Kj21MzgzMTk";
public static final String GAME_CONTENTID = "Kj21NjIxNTk";
public static final String UPLOAD_CONTENTID = "Kj21NjA1NTE";
// *************** 公共 ***************
public static final String VERSION_INFO = "/kjy/mp/version/info";
public static final String ISVIPSUBSCRIBE = "/kjy/mp/seller/isVipSubscribe";
public static final String USER_INFO = "/kjy/mp/user/info";
public static final String FORWARD = "/kjy/mp/forward";
public static final String GETSCID = "/kjy/mp/seller/getScId";
public static final String HASALREADYLIKE = "/kjy/mp/interaction/hasAlreadyLike";
// *************** 支付 ***************
public static final String PAY_GETMIDDLEDETAIL = "/kjy/mp/payMiddle/getMiddleDetail";
public static final String PAY_HASSITESALEVALID = "/kjy/mp/seller/dist/hasSiteSaleValid";
public static final String PAY_GETPROMOCODE = "/kjy/order/getPromoCode";
public static final String PAY_COMBOLIST = "/kjy/mp/combo/list/v2?code=";
public static final String PAY_ORDERCREATE = "/kjy/order/create";
public static final String PAY_ORDERCANCEL = "/kjy/order/cancel";
public static final String PAY_VERSIONEXCHANGE = "/kjy/mp/version/exchange";
public static final String PAY_DISTRIBUTE = "/kjy/sp/visitorPayment/distribute";
// *************** 名片 ***************
public static final String SELLERCARD_TOPOFDETAIL = "/kjy/mp/sellerCardV5/topOfDetail";
public static final String SELLERCARD_EDITBASEINFO = "/kjy/mp/sellerCard/editBaseInfo";
public static final String SELLERCARD_PERSONALPROFILE = "/kjy/mp/sellerCardV5/personalProfile";
public static final String SELLERCARD_EDITMAJORGOODAUTH = "/kjy/mp/sellerCard/editMajorGoodAuth";
public static final String SELLERCARD_APPRAISELISTNEW = "/kjy/mp/sellerCardV5/appraiseListNew";
public static final String SELLERCARD_GETQUESTIONS = "/kjy/mp/sellerCardV5/getQuestions";
public static final String SELLERCARD_ISDISPLAYACTIVITY = "/kjy/mp/clue/activity/isDisplayActivity";
public static final String SELLERCARD_COMPANYLIST = "/kjy/mp/company/list";
public static final String SELLERCARD_SELLERCARDCASENEW = "/kjy/mp/sellerCardV5/sellerCardCasesNew";
public static final String SELLERCARD_PRODUCTLIST = "/kjy/mp/sellerCardV5/productList";
public static final String SELLERCARD_GETSELLERCARDCONFIG = "/kjy/mp/sellerConfig/getSellerCardConfig";
public static final String SELLERCARD_GETSELLERCARDSTYLE = "/kjy/mp/sellerConfig/getSellerCardStyle";
public static final String SELLERCARD_TOPOFCONTENT = "/kjy/mp/sellerCardV5/topOfContent";
public static final String SELLERCARD_BOTTOMOFCONTENT = "/kjy/mp/sellerCardV5/bottomOfContent";
// *************** 上传 ***************
public static final String UPLOAD = "/kjy/mp/seller/import/upload";
public static final String UPLOAD_TASKSTATUS = "/kjy/mp/seller/import/taskStatus";
public static final String UPLOAD_CONTENTDETAIL = "/kjy/mp/content/detail";
public static final String UPLOAD_UPDATEANDSHARE = "/kjy/mp/content/updateAndShare";
public static final String UPLOAD_UPLOADVEDIO = "/kjy/mp/upload/video";
public static final String UPLOAD_SELLERUPLOADVEDIO = "/kjy/mp/seller/upload/video";
public static final String UPLOAD_HOT = "/kjy/mp/seller/import/hot";
public static final String UPLOAD_VIDEOHOT = "/kjy/mp/seller/import/video/hot";
public static final String UPLOAD_LIST = "/kjy/mp/seller/import/list";
public static final String UPLOAD_UNBIND = "/kjy/mp/seller/import/unbind";
// *************** 新手任务 ***************
public static final String NOVICE_LIST = "/kjy/mp/seller/novice/list";
public static final String NOVICE_MONGOLIANLAYERISPLAY = "/kjy/mp/seller/novice/mongolianLayerDisplay";
// *************** 谁看过我 ***************
public static final String WHOSAWME_CUSTCLUELISTV2 = "/kjy/mp/whoSawMe/custClueList/v2";
// *************** 文章 ***************
public static final String ARTICLE_H5INFO = "/kjy/mp/article/h5info";
public static final String ARTICLE_GETEXPINFO = "/kjy/mp/explosioncontent/getexpinfo";
public static final String ARTICLE_GETTAGTYPESBYCONTENTID = "/kjy/mp/explosionContent/resource/getTagTypesByContentId";
// ************** 设置中心 ***************
public static final String SELLERCONFIG_EDITCONFIG = "/kjy/mp/sellerConfig/editConfig";
}
package com.kjj.qa.utils;
import static com.kjj.qa.config.BasicConfig.*;
import java.util.HashMap;
import java.util.Map;
......@@ -10,9 +10,12 @@ public class DingTalkUtil {
//测试结果
context = "【测试结果】\n"
+ context
+ "接口数:"+ apiCount + "\n"
+ "报告地址: http://10.254.187.25/view/kjj_test/job/kejiji_interface/ws/test-output/report.html\n"
+ "@李浩弘 @张震 @别湘灵 @张艳玲 @张慧锋";
System.out.println(context);
Map<String, Object> contentParams = new HashMap<String, Object>();
contentParams.put("content",context);
......@@ -22,8 +25,8 @@ public class DingTalkUtil {
params.put("text",contentParams);
//发起dingding机器人通知
NetworkUtil network = NetworkUtil.getInstance();
network.dingTalkRobot(params);
// NetworkUtil network = NetworkUtil.getInstance();
// network.dingTalkRobot(params);
}
......
package com.kjj.qa.utils;
import static com.kjj.qa.config.BasicConfig.*;
import static io.restassured.RestAssured.*;
import static io.restassured.matcher.RestAssuredMatchers.*;
import static org.hamcrest.Matchers.*;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPath;
import com.mysql.cj.x.protobuf.MysqlxDatatypes;
import io.restassured.http.Cookies;
import io.restassured.path.json.JsonPath;
import io.restassured.response.Response;
import javax.print.DocFlavor;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
......@@ -31,37 +25,17 @@ public class NetworkUtil {
public Map<String, Object> getFileHeaders() { return agentHeaders; }
public void setFileHeadersHeaders(Map<String, Object> fileHeaders) { this.fileHeaders = fileHeaders; }
//代理人的tku
public String agentTku = new String("T3gM31f18jAWdkgg3kyGYmYH8Vsrd5BdQJ7fpFfRikMJJQycJFXTTxtqATmEN3ECa4TnKjKvtbazYb3e3X");
public String getAgentTku() { return agentTku; }
public void setAgentTku(String agentTku) { this.agentTku = agentTku; }
//访客的tku
public String visitorTku = new String("QoEVdKqFrDvq89RmQPxDArCNwjwotBjn4sfHr62Dv8Z1A4gRH6cxqrSLJP42ywZHttE");
public String getVisitorTku() { return visitorTku; }
public void setVisitorTku(String visitorTku) { this.visitorTku = visitorTku; }
// 钉钉的 headers
public Map<String, Object> dingTalkHeaders = new HashMap<String, Object>();
public Map<String, Object> getDingTalkHeaders() { return dingTalkHeaders; }
public void setDingTalkHeaders(Map<String, Object> dingTalkHeaders) { this.dingTalkHeaders = dingTalkHeaders; }
//客集集域名
// private static String host = "https://kjj.m.duiba.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";
private volatile static NetworkUtil network;
// 构造函数 初始化tku、content-type
private NetworkUtil (){
//cookies中的tku
agentCookies.put("tku",this.agentTku);
agentCookies.put("tku",AGENT_TKU);
//json类型的headers
agentHeaders.put("Content-Type","application/json");
//二进制文件的headers
......@@ -91,7 +65,7 @@ public class NetworkUtil {
return given()
.cookies(agentCookies)
.headers(agentHeaders)
.get(host+path);
.get(HOST + path);
}
// get 带参请求
......@@ -100,7 +74,7 @@ public class NetworkUtil {
.cookies(agentCookies)
.headers(agentHeaders)
.params(params)
.get(host + path);
.get(HOST + path);
}
// post 不帶参请求
......@@ -108,7 +82,7 @@ public class NetworkUtil {
return given()
.cookies(agentCookies)
.headers(agentHeaders)
.post(host + path);
.post(HOST + path);
}
// post 带参请求
......@@ -118,7 +92,7 @@ public class NetworkUtil {
.cookies(agentCookies)
.headers(agentHeaders)
.body(jsonStr)
.post(host + path);
.post(HOST + path);
}
// post 文件上传
......@@ -126,8 +100,8 @@ public class NetworkUtil {
return given()
.cookies(agentCookies)
.headers(fileHeaders)
.multiPart("file",new File(filePath))
.post(host + path);
.multiPart("file",new File(filePath))
.post(HOST + path);
}
......@@ -138,13 +112,25 @@ public class NetworkUtil {
return given()
.headers(dingTalkHeaders)
.body(jsonStr)
.post(dingtalkPath);
.post(DINGTALKPATH);
}
//带参的接口信息
public String message(Map<String, Object> params, String path, String errorMessage){
return "\n" + "path: " + path +
"\n" + "params: " + params +
"\n" + "message: " + errorMessage;
}
//不带参的接口信息
public String message(String path, String errorMessage){
return "\n" + "path: " + path +
"\n" + "message: " + errorMessage;
}
public static void main(String[] args) {
NetworkUtil network = NetworkUtil.getInstance();
System.out.println(network.agentTku);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="客集集-测试结果" verbose="1" thread-count="3">
<!-- <test preserve-order="true" name="首页" >-->
<!-- <classes>-->
<!-- <class name="com.kjj.qa.cases.Home"/>-->
<!-- </classes>-->
<!-- </test>-->
<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>
<class name="com.kjj.qa.cases.Pay"/>
</classes>
</test>
<test preserve-order="true" name="名片" >
<test preserve-order="true" name="名片">
<classes>
<class name="com.kjj.qa.cases.SellerCard"/>
</classes>
</test>
<!-- <test preserve-order="true" name="上传" >-->
<!-- <classes>-->
<!-- <class name="com.kjj.qa.cases.Upload"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- <test preserve-order="true" name="新手任务" >-->
<!-- <classes>-->
<!-- <class name="com.kjj.qa.cases.NewTask"/>-->
<!-- </classes>-->
<!-- </test>-->
<test preserve-order="true" name="上传">
<classes>
<class name="com.kjj.qa.cases.Upload"/>
</classes>
</test>
<test preserve-order="true" name="新手任务">
<classes>
<class name="com.kjj.qa.cases.Novice"/>
</classes>
</test>
<!-- 监听器-->
<listeners>
<listener class-name="com.kjj.qa.config.ExtentTestNGIReporterListener"/>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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