Commit 10afbfff by 左磊磊

add:修改代码错误的内容

parent 8ae55915
......@@ -118,10 +118,10 @@ public class BaseCase {
}
public boolean assertSqlB(String expectValue, String beforeSqlResult) {
public boolean assertSqlB(String beforeSqlResult,String afterSqlResult) {
// 判断如果B段SQL执行首次为空,第二次非空
boolean flag = false;
if (beforeSqlResult == null && expectValue != null) {
if (beforeSqlResult == null && afterSqlResult != null) {
flag = true;
}
return flag;
......
......@@ -19,8 +19,8 @@ import java.math.BigDecimal;
import java.text.DecimalFormat;
public class ServerCase extends BaseCase {
@Test(dataProvider = "data1", description = "推送消息-校验第1段和第2段") // DTO数据传输
@Description("推送消息-校验第1段和第2段")
@Test(dataProvider = "data1", description = "1A:A段和B段sql完全匹配") // DTO数据传输
@Description("1A:A段和B段sql完全匹配")
public void testManager1A(API api, Case cas) throws Exception {
//0、执行前休眠30秒
Thread.sleep(1000 * 40);
......@@ -62,23 +62,19 @@ public class ServerCase extends BaseCase {
//8、添加断言回写内容
String assertContent = (assertResponseFlag && sqlAFlag && sqlBFlag) ? "Pass" : "Fail";
addWBD(Integer.parseInt(cas.getId()), Constants.ASSERT_RESULT_CELL_NUM, assertContent);
//9、添加日志
//10、报表断言
Assert.assertEquals(assertContent, "Pass");
}
// 使用Excel文件传输接口信息和请求信息
@DataProvider(name = "data1")
public Object[][] data1() {
Object[][] data = ExcelUtils.getAPIAndCaseByApiId("1"); // 传参apiID
return data;
}
@Test(dataProvider = "data2", description = "2B:") // DTO数据传输
@Description("2B:")
@Test(dataProvider = "data2", description = "2B:B段sql部分匹配")
@Description("2B:B段sql部分匹配")
public void testManager2B(API api, Case cas) throws Exception {
Thread.sleep(1000 * 30);
Thread.sleep(1000 * 40);
String params = replace(cas.getParams());
String Bsql = replace(cas.getCheckBSQL());
cas.setParams(params);
......@@ -86,15 +82,18 @@ public class ServerCase extends BaseCase {
Object beforeBSqlResult = SqlUtils.querySingle(cas.getCheckBSQL());
String body = call(api, cas, false);
AuthorizationUtils.storeToken(body);
// System.out.println(AuthorizationUtils.env);
boolean assertResponseFlag = assertResponse(cas, body);
addWBD(Integer.parseInt(cas.getId()), Constants.ACTURL_WRITER_BACK_CELL_NUM, body);
System.out.println("B-sql: " + cas.getCheckBSQL());
Thread.sleep(1000 * 30);
Thread.sleep(1000 * 30); //验证B段SQL的休眠时间60秒
Object afterBSqlResult = SqlUtils.querySingle(cas.getCheckBSQL());
boolean sqlBFlag = assertSql(cas.getbExpectValue(), beforeBSqlResult == null ? null : beforeBSqlResult.toString(), afterBSqlResult == null ? null : afterBSqlResult.toString());
//7-2、B段数据库断言
boolean sqlBFlag = assertSqlB(beforeBSqlResult == null ? null : beforeBSqlResult.toString(), afterBSqlResult == null ? null : afterBSqlResult.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");
......@@ -131,7 +130,6 @@ public class ServerCase extends BaseCase {
Assert.assertEquals(assertContent, "Pass");
}
// 使用Excel文件传输接口信息和请求信息
@DataProvider(name = "data3")
public Object[][] data3() {
Object[][] data = ExcelUtils.getAPIAndCaseByApiId("3"); // 传参apiID
......@@ -175,7 +173,7 @@ public class ServerCase extends BaseCase {
addWBD(Integer.parseInt(cas.getId()), Constants.A_ASSERT_RESULT_CELL_NUM, assertSqlAFlag);
System.out.println("数据库A-sql断言结果:" + sqlAFlag);
//7-2、B段数据库断言
boolean sqlBFlag=assertSqlB(cas.getbExpectValue(),beforeBSqlResult == null ? null : beforeBSqlResult.toString());
boolean sqlBFlag = assertSqlB(beforeBSqlResult == null ? null : beforeBSqlResult.toString(), afterBSqlResult == null ? null : afterBSqlResult.toString());
String assertSqlBFlag = (sqlBFlag) ? "Pass" : "Fail";
addWBD(Integer.parseInt(cas.getId()), Constants.B_ASSERT_RESULT_CELL_NUM, assertSqlBFlag);
System.out.println("数据库B-sql断言结果:" + sqlBFlag);
......@@ -193,18 +191,20 @@ public class ServerCase extends BaseCase {
}
@Test(dataProvider = "data5", description = "5E:B段sql部分匹配")
@Description("5E:B段sql部分匹配")
@Test(dataProvider = "data5", description = "5E:A段sql完全匹配,B段sql部分匹配,适用于作品应用")
@Description("5E:A段sql完全匹配,B段sql部分匹配,适用于作品应用")
public void testManager5E(API api, Case cas) throws Exception {
//0、执行前休眠30秒
Thread.sleep(1000 * 40);
//1、参数化替换
String params = replace(cas.getParams());
String sql = replace(cas.getCheckSQL());
String Bsql = replace(cas.getCheckBSQL());
cas.setParams(params);
cas.setCheckSQL(sql);
cas.setCheckBSQL(Bsql);
//2、数据库前置查询结果(断言必须在接口执行前后都查询)
Object beforeASqlResult = SqlUtils.querySingle(cas.getCheckSQL());
Object beforeBSqlResult = SqlUtils.querySingle(cas.getCheckBSQL());
//3、调用接口
String body = call(api, cas, false);
......@@ -216,26 +216,30 @@ public class ServerCase extends BaseCase {
//5、添加接口响应回写excel内容
addWBD(Integer.parseInt(cas.getId()), Constants.ACTURL_WRITER_BACK_CELL_NUM, body);
//6、数据库后置查询结果
System.out.println("A-sql: " + cas.getCheckSQL());
Object afterASqlResult = SqlUtils.querySingle(cas.getCheckSQL());
System.out.println("B-sql: " + cas.getCheckBSQL());
Thread.sleep(1000 * 30); //验证B段SQL的休眠时间60秒
Object afterBSqlResult = SqlUtils.querySingle(cas.getCheckBSQL());
//7-1、A段数据库断言
boolean sqlAFlag = assertSql(cas.getaExpectValue(), beforeASqlResult == null ? null : beforeASqlResult.toString(), afterASqlResult == null ? null : afterASqlResult.toString());
String assertSqlAFlag = (sqlAFlag) ? "Pass" : "Fail";
addWBD(Integer.parseInt(cas.getId()), Constants.A_ASSERT_RESULT_CELL_NUM, assertSqlAFlag);
System.out.println("数据库A-sql断言结果:" + sqlAFlag);
//7-2、B段数据库断言
boolean sqlBFlag=assertSqlB(cas.getbExpectValue(),beforeBSqlResult == null ? null : beforeBSqlResult.toString());
boolean sqlBFlag = assertSqlB(beforeBSqlResult == null ? null : beforeBSqlResult.toString(), afterBSqlResult == null ? null : afterBSqlResult.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";
String assertContent = (assertResponseFlag && sqlAFlag && 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
Object[][] data = ExcelUtils.getAPIAndCaseByApiId("5");
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