Commit 8ae55915 by 左磊磊

add:2023年8月7日新增代码

parent b42da6b0
......@@ -8,5 +8,5 @@
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="18" project-jdk-type="JavaSDK" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="18" project-jdk-type="JavaSDK" />
</project>
\ No newline at end of file
......@@ -21,7 +21,7 @@ import java.text.DecimalFormat;
public class ServerCase extends BaseCase {
@Test(dataProvider = "data1", description = "推送消息-校验第1段和第2段") // DTO数据传输
@Description("推送消息-校验第1段和第2段")
public void testManager(API api, Case cas) throws Exception {
public void testManager1A(API api, Case cas) throws Exception {
//0、执行前休眠30秒
Thread.sleep(1000 * 40);
//1、参数化替换
......@@ -75,9 +75,9 @@ public class ServerCase extends BaseCase {
}
@Test(dataProvider = "data2", description = "推送图片-校验第2段") // DTO数据传输
@Description("推送图片-校验第2段")
public void testManager2(API api, Case cas) throws Exception {
@Test(dataProvider = "data2", description = "2B:") // DTO数据传输
@Description("2B:")
public void testManager2B(API api, Case cas) throws Exception {
Thread.sleep(1000 * 30);
String params = replace(cas.getParams());
String Bsql = replace(cas.getCheckBSQL());
......@@ -107,9 +107,9 @@ public class ServerCase extends BaseCase {
return data;
}
@Test(dataProvider = "data3", description = "推送消息-校验第1段") // DTO数据传输
@Description("推送消息-校验第1段")
public void testManager3(API api, Case cas) throws Exception {
@Test(dataProvider = "data3", description = "3C:A段sql完全匹配") // DTO数据传输
@Description("3C:A段sql完全匹配")
public void testManager3C(API api, Case cas) throws Exception {
Thread.sleep(1000 * 40);
String params = replace(cas.getParams());
String sql = replace(cas.getCheckSQL());
......@@ -139,9 +139,9 @@ public class ServerCase extends BaseCase {
}
@Test(dataProvider = "data4", description = "推送消息-第2段部分匹配判断") // DTO数据传输
@Description("推送消息-第2段部分匹配判断")
public void testManager4(API api, Case cas) throws Exception {
@Test(dataProvider = "data4", description = "4D:A段sql完全匹配,B段sql部分匹配") // DTO数据传输
@Description("4D:A段sql完全匹配,B段sql部分匹配")
public void testManager4D(API api, Case cas) throws Exception {
//0、执行前休眠30秒
Thread.sleep(1000 * 40);
//1、参数化替换
......@@ -194,4 +194,48 @@ public class ServerCase extends BaseCase {
@Test(dataProvider = "data5", description = "5E:B段sql部分匹配")
@Description("5E:B段sql部分匹配")
public void testManager5E(API api, Case cas) throws Exception {
//0、执行前休眠30秒
Thread.sleep(1000 * 40);
//1、参数化替换
String params = replace(cas.getParams());
String Bsql = replace(cas.getCheckBSQL());
cas.setParams(params);
cas.setCheckBSQL(Bsql);
//2、数据库前置查询结果(断言必须在接口执行前后都查询)
Object beforeBSqlResult = SqlUtils.querySingle(cas.getCheckBSQL());
//3、调用接口
String body = call(api, cas, false);
// 3.1 将登录的token存储(仅限于登录接口特有)
AuthorizationUtils.storeToken(body);
// System.out.println(AuthorizationUtils.env);
//4、断言响应结果,Excel中预期响应数据与实际响应数据进行对比
boolean assertResponseFlag = assertResponse(cas, body);
//5、添加接口响应回写excel内容
addWBD(Integer.parseInt(cas.getId()), Constants.ACTURL_WRITER_BACK_CELL_NUM, body);
//6、数据库后置查询结果
System.out.println("B-sql: " + cas.getCheckBSQL());
Thread.sleep(1000 * 30); //验证B段SQL的休眠时间60秒
Object afterBSqlResult = SqlUtils.querySingle(cas.getCheckBSQL());
//7-2、B段数据库断言
boolean sqlBFlag=assertSqlB(cas.getbExpectValue(),beforeBSqlResult == null ? null : beforeBSqlResult.toString());
String assertSqlBFlag = (sqlBFlag) ? "Pass" : "Fail";
addWBD(Integer.parseInt(cas.getId()), Constants.B_ASSERT_RESULT_CELL_NUM, assertSqlBFlag);
System.out.println("数据库B-sql断言结果:" + sqlBFlag);
//8、添加断言回写内容
String assertContent = (assertResponseFlag && sqlBFlag) ? "Pass" : "Fail";
addWBD(Integer.parseInt(cas.getId()), Constants.ASSERT_RESULT_CELL_NUM, assertContent);
Assert.assertEquals(assertContent, "Pass");
}
// 使用Excel文件传输接口信息和请求信息
@DataProvider(name = "data5")
public Object[][] data5() {
Object[][] data = ExcelUtils.getAPIAndCaseByApiId("5"); // 传参apiID
return data;
}
}
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