Commit 3e828a0c authored by 李浩弘's avatar 李浩弘

Merge branch 'test/20200403-test' into 'master'

第一次demo提交

See merge request test-group/kejiji!1
parents 2d816b98 69532175
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="masterDetails">
<states>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
\ No newline at end of file
# Default ignored files
/workspace.xml
\ No newline at end of file
kjj
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="kjj" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>kjj</groupId>
<artifactId>kjj</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- maven 参数配置,这里引用不同的testng.xml -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- maven 引用依赖不同的jar -->
<dependencies>
<!--导入TestNG依赖包-->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
<scope>test</scope>
</dependency>
<!-- 导入fastjson包 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
</dependency>
<!-- rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.0.0</version>
<scope>test</scope>
</dependency>
<!-- 导入Mysql数据库链接jar包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
<!-- 引入poi,解析workbook视图 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<!-- 依赖reportNg 关联testNg-->
<!-- <dependency>-->
<!-- <groupId>org.uncommons</groupId>-->
<!-- <artifactId>reportng</artifactId>-->
<!-- <version>1.1.4</version>-->
<!-- <scope>test</scope>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <groupId>org.testng</groupId>-->
<!-- <artifactId>testng</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<!-- ExtentReports测试报告 关联testNg-->
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.0</version>
</dependency>
<dependency>
<groupId>com.vimalselvam</groupId>
<artifactId>testng-extentsreport</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.6</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.2.2</version>
</dependency>
</dependencies>
<!-- 编译插件 -->
<build>
<defaultGoal>compile</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<encoding>utf-8</encoding>
<!--源代码的编译-->
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<suiteXmlFiles>
<!-- -->
<suiteXmlFile>testNG.xml</suiteXmlFile>
</suiteXmlFiles>
<properties>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
</properties>
<!--即使测试失败,也继续下面的测试-->
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
<?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="支付" >
<classes>
<class name="com.kjj.qa.cases.Pay"/>
</classes>
</test>
<!-- <test preserve-order="true" name="名片" >-->
<!-- <classes>-->
<!-- <class name="com.kjj.qa.cases.SellerCard"/>-->
<!-- </classes>-->
<!-- </test>-->
<!-- 监听器-->
<listeners>
<listener class-name="com.kjj.qa.config.ExtentTestNGIReporterListener"/>
</listeners>
</suite>
<!-- Suite -->
<!--
suite定义一个测试套件,可以设置是否使用多线程,可包含多个测试用例或者测试group
parallel = classes  每个测试用例class级别多线程
thread-count =3  线程数为5,可同时执行3个case
preserve-order = true   classes和methods按照配置中的顺序执行,false为乱序执行。(If you want the classes and methods listed in this file to be run in an unpredictible order, set the preserve-order attribute to false)
parameter 标签传递参数
-->
package com.kjj.qa.cases;
import com.kjj.qa.services.NetworkOperation;
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.HashMap;
import java.util.Map;
public class Home {
private NetworkOperation network = new NetworkOperation();
// http://kjj.m.duibatest.com.cn/kjy/mp/developer/changeUser?uid=1515
@BeforeClass
public void setUp() {
// 代理人 cookies
network.agentCookies.put("tku","3wSM7Cd4wsesMcuzVhBQVGVupkmB3tT1JHyRbv9sK6ts7f6P67rmuygUqGfPc2Xd9YduvdByMocmpuzNMzKKWd48");
network.agentCookies.put("acw_tc","76b20ff215756198852864366e248d9e6bfb989ae8f073e81a05f23e6ef703");
network.agentHeaders.put("Content-Type","application/json");
// 访客 cookies
network.vistorCookies.put("tku","fcedkR2oRAVAoStCWGx7Y45krm9opxbQvd76nvAKqXQwmDyHyQyEiXyjEBjzRrk9hdVhppStVd5iz6GcBx8ghW");
network.vistorCookies.put("acw_tc","76b20fea15774130899093358e57cc742bc2ebcc713ece289b4e9c26ed8785");
network.vistorHeaders.put("Content-Type","application/json");
}
@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.
package com.kjj.qa.cases;
import com.alibaba.fastjson.JSONObject;
import com.kjj.qa.services.NetworkOperation;
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.HashMap;
import java.util.Map;
public class SellerCard {
private NetworkOperation network = new NetworkOperation();
@BeforeClass
public void setUp() {
// 代理人 cookies
network.agentCookies.put("tku","T3gM31f18jAWvBFkQfN29cBnRJPVhN64pvvU1T2tkuQe24NggZnSnByQ8yncFGVAxui9GZ4veufsYPCcG2");
// network.agentCookies.put("acw_tc","76b20fec15850493922213781e346d81600bc01e6019c96a7e36d6b829aef3");
network.agentHeaders.put("Content-Type","application/json");
}
@Test (description = "详情页顶部",priority = 1) //priorty 方法执行优先级
public void 详情页顶部() throws IOException {
Response topDetailResponse = network.getResponse("/kjy/mp/sellerCardV5/topOfDetail");
String name = topDetailResponse.jsonPath().getString("data.sellerName");
Assert.assertEquals(name,"小葡萄","详情页顶部:获取用户信息失败!");
}
@Test (description = "个人介绍",priority = 2)
public void 个人介绍() throws IOException{
//拿到用户scid
Response topDetailResponse = network.getResponse("/kjy/mp/sellerCardV5/topOfDetail");
String scid = topDetailResponse.jsonPath().getString("data.scid");
Map<String, Object> params = new HashMap<String, Object>();
params.put("scid",scid);
Response personalProfileResponse = network.getResponse(params,"/kjy/mp/sellerCardV5/personalProfile");
String profile = personalProfileResponse.jsonPath().getString("data.personalIntro");
Assert.assertEquals(profile,"我在行业内深耕多年,经验丰富,具备过硬的专业素质,深受客户喜爱和支持。","个人介绍:获取介绍失败");
}
}
package com.kjj.qa.config;
import com.aventstack.extentreports.ExtentReports;
import com.aventstack.extentreports.ExtentTest;
import com.aventstack.extentreports.ResourceCDN;
import com.aventstack.extentreports.Status;
import com.aventstack.extentreports.model.TestAttribute;
import com.aventstack.extentreports.reporter.ExtentHtmlReporter;
import com.aventstack.extentreports.reporter.configuration.ChartLocation;
import org.testng.*;
import org.testng.xml.XmlSuite;
import java.io.File;
import java.util.*;
import com.kjj.qa.utils.DingTalkUtil;
public class ExtentTestNGIReporterListener implements IReporter {
// 生成的路径以及文件名
private static final String OUTPUT_FOLDER = "test-output/";
//注意这里如果用index.html可能会导致testng的report会覆盖它
private static final String FILE_NAME = "report.html";
private ExtentReports extent;
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
init();
boolean createSuiteNode = false;
//判断执行用例的队列是否有多个
if (suites.size() > 0) {
createSuiteNode = true;
}
for (ISuite suite : suites) {
Map<String, ISuiteResult> result = suite.getResults();
// 如果suite里面没有任何用例,直接跳过,不在报告里生成
if (result.size() == 0) {
continue;
}
// 统计suite下的成功、失败、跳过的总用例数
int suiteFailSize = 0;
int suitePassSize = 0;
int suiteSkipSize = 0;
ExtentTest suiteTest = null;
// 存在多个suite的情况下,在报告中将同一个suite的测试结果归为一类,创建一级节点。
if (createSuiteNode) {
suiteTest = extent.createTest(suite.getName()).assignCategory(suite.getName());
}
boolean createSuiteResultNode = false;
if (result.size() > 1) {
createSuiteResultNode = true;
}
for (ISuiteResult r : result.values()) {
ExtentTest resultNode;
ITestContext context = r.getTestContext();
if (createSuiteResultNode) {
// 没有创建suite的情况下,将在SuiteResult的创建为一级节点,否则创建为suite的一个子节点。
if (null == suiteTest) {
resultNode = extent.createTest(r.getTestContext().getName());
} else {
resultNode = suiteTest.createNode(r.getTestContext().getName());
}
} else {
resultNode = suiteTest;
}
if (resultNode != null) {
resultNode.getModel().setName(suite.getName() + " : " + r.getTestContext().getName());
if (resultNode.getModel().hasCategory()) {
resultNode.assignCategory(r.getTestContext().getName());
} else {
resultNode.assignCategory(suite.getName(), r.getTestContext().getName());
}
resultNode.getModel().setStartTime(r.getTestContext().getStartDate());
resultNode.getModel().setEndTime(r.getTestContext().getEndDate());
// 统计SuiteResult下的数据
int passSize = r.getTestContext().getPassedTests().size();
int failSize = r.getTestContext().getFailedTests().size();
int skipSize = r.getTestContext().getSkippedTests().size();
suitePassSize += passSize;
suiteFailSize += failSize;
suiteSkipSize += skipSize;
if (failSize > 0) {
resultNode.getModel().setStatus(Status.FAIL);
}
resultNode.getModel().setDescription(
String.format("Pass: %s ; Fail: %s ; Skip: %s ;", passSize, failSize, skipSize));
}
buildTestNodes(resultNode, context.getFailedTests(), Status.FAIL);
buildTestNodes(resultNode, context.getSkippedTests(), Status.SKIP);
buildTestNodes(resultNode, context.getPassedTests(), Status.PASS);
}
if (suiteTest != null) {
suiteTest.getModel().setDescription(
String.format("Pass: %s ; Fail: %s ; Skip: %s ;", suitePassSize, suiteFailSize, suiteSkipSize));
if (suiteFailSize > 0) {
suiteTest.getModel().setStatus(Status.FAIL);
}
}
String context = String.format("通过: %s ; 失败: %s ; 跳过: %s ;", suitePassSize, suiteFailSize, suiteSkipSize);
try {
DingTalkUtil.sendVal(context);
} catch (Exception e) {
e.printStackTrace();
}
}
// for (String s : Reporter.getOutput()) {
// extent.setTestRunnerOutput(s);
// }
extent.flush();
}
private void init() {
// 文件夹不存在的话进行创建
File reportDir = new File(OUTPUT_FOLDER);
if (!reportDir.exists() && !reportDir.isDirectory()) {
reportDir.mkdir();
}
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(OUTPUT_FOLDER + FILE_NAME);
// 设置静态文件的DNS
//怎么样解决cdn.rawgit.com访问不了的情况
htmlReporter.config().setResourceCDN(ResourceCDN.EXTENTREPORTS);
htmlReporter.config().setDocumentTitle("客集集-自动化测试报告");
htmlReporter.config().setReportName("客集集-自动化测试报告");
htmlReporter.config().setChartVisibilityOnOpen(true);
//报表位置
htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
// htmlReporter.config().setTheme(Theme.STANDARD);
htmlReporter.config().setCSS(".node.level-1 ul{ display:none;} .node.level-1.active ul{display:block;}");
extent = new ExtentReports();
extent.attachReporter(htmlReporter);
extent.setReportUsesManualConfiguration(true);
}
private void buildTestNodes(ExtentTest extenttest, IResultMap tests, Status status) {
// 存在父节点时,获取父节点的标签
String[] categories = new String[0];
if (extenttest != null) {
List<TestAttribute> categoryList = extenttest.getModel().getCategoryContext().getAll();
categories = new String[categoryList.size()];
for (int index = 0; index < categoryList.size(); index++) {
categories[index] = categoryList.get(index).getName();
}
}
ExtentTest test;
if (tests.size() > 0) {
// 调整用例排序,按时间排序
Set<ITestResult> treeSet = new TreeSet<ITestResult>(new Comparator<ITestResult>() {
@Override
public int compare(ITestResult o1, ITestResult o2) {
return o1.getStartMillis() < o2.getStartMillis() ? -1 : 1;
}
});
treeSet.addAll(tests.getAllResults());
for (ITestResult result : treeSet) {
Object[] parameters = result.getParameters();
String name = "";
// 如果有参数,则使用参数的toString组合代替报告中的name
for (Object param : parameters) {
name += param.toString();
}
if (name.length() > 0) {
if (name.length() > 50) {
name = name.substring(0, 49) + "...";
}
} else {
name = result.getMethod().getMethodName();
}
if (extenttest == null) {
test = extent.createTest(name);
} else {
// 作为子节点进行创建时,设置同父节点的标签一致,便于报告检索。
test = extenttest.createNode(name).assignCategory(categories);
}
// test.getModel().setDescription(description.toString());
// test = extent.createTest(result.getMethod().getMethodName());
for (String group : result.getMethod().getGroups())
test.assignCategory(group);
List<String> outputList = Reporter.getOutput(result);
for (String output : outputList) {
// 将用例的log输出报告中
test.debug(output);
}
if (result.getThrowable() != null) {
test.log(status, result.getThrowable());
} else {
test.log(status, "Test " + status.toString().toLowerCase() + "ed");
}
test.getModel().setStartTime(getTime(result.getStartMillis()));
test.getModel().setEndTime(getTime(result.getEndMillis()));
}
}
}
private Date getTime(long millis) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(millis);
return calendar.getTime();
}
}
package com.kjj.qa.services;
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.util.HashMap;
import java.util.Map;
public class NetworkOperation {
// 代理人的 cookies和headers
public Map<String, Object> agentCookies = new HashMap<String, Object>();
public Map<String, Object> getAgentCookies() { return agentCookies; }
public void setAgentCookies(Map<String, Object> agentCookies) { this.agentCookies = agentCookies; }
public Map<String, Object> agentHeaders = new HashMap<String, Object>();
public Map<String, Object> getAgentHeaders() { return agentHeaders; }
public void setAgentHeaders(Map<String, Object> agentHeaders) { this.agentHeaders = agentHeaders; }
// 访客的 cookies和headers
public Map<String, Object> vistorCookies = new HashMap<String, Object>();
public Map<String, Object> getVistorCookies() { return vistorCookies; }
public void setVistorCookies(Map<String, Object> vistorCookies) { this.vistorCookies = vistorCookies; }
public Map<String, Object> vistorHeaders = new HashMap<String, Object>();
public Map<String, Object> getVistorHeaders() { return vistorHeaders; }
public void setVistorHeaders(Map<String, Object> vistorHeaders) { this.vistorHeaders = vistorHeaders; }
// 钉钉的 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";
// get 不带参请求
public Response getResponse(String path) {
return given()
.cookies(agentCookies)
.headers(agentHeaders)
.get(host+path);
}
// get 带参请求
public Response getResponse(Map<String, Object> params, String path) {
return given()
.cookies(agentCookies)
.headers(agentHeaders)
.params(params)
.get(host+path);
}
// post 不帶参请求
public Response PostResponse(String path) {
return given()
.cookies(agentCookies)
.headers(agentHeaders)
.post(host+path);
}
// post 带参请求
public Response PostResponse(String jsonStr, String path) {
return given()
.cookies(agentCookies)
.headers(agentHeaders)
.body(jsonStr)
.post(host+path);
}
// post 带参请求
public Response dingTalkRobot(String jsonStr) {
dingTalkHeaders.put("Content-Type","application/json;charset=utf-8");
return given()
.headers(dingTalkHeaders)
.body(jsonStr)
.post(dingtalkPath);
}
//用户行为
public Response visitorBehavior(Map<String, Object> params, String path){
return given()
.cookies(vistorCookies)
.headers(vistorHeaders)
.params(params)
.get(host+path);
}
public static void main(String[] args) {
// NetworkOperation network = new NetworkOperation();
//
// Map<String,Object> json=new HashMap();
// Map<String,Object> text=new HashMap();
// json.put("msgtype","text");
//
// text.put("content","报告 :");
// json.put("text",text);
// Response res = network.dingTalkRobot(json);
}
}
package com.kjj.qa.utils;
import com.kjj.qa.services.NetworkOperation;
import java.util.HashMap;
public class DingTalkUtil {
//通过钉钉机器人发送消息到钉钉群中
public static void sendVal(String context)throws Exception{
String entityString ="{'msgtype': 'text', 'text': {'content': '测试结果:\n"+context+"'}}";
System.out.println(entityString);
// NetworkOperation network = new NetworkOperation();
// network.dingTalkRobot(entityString); //发起请求
}
public static void main(String[] args) {
//获取当前系统时间
// long currentTime = System.currentTimeMillis();
// SimpleDateFormat formatter = new SimpleDateFormat("yyyy年-MM月dd日-HH时mm分ss秒");
// Date date = new Date(currentTime);
// System.out.println(formatter.format(date));
// Reporter.log(formatter.format(date) + splitTimeAndMsg + msg, true);
}
}
package com.kjj.qa.utils;
public final class KjyUtil {
}
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