判断失败步骤后,跳转逻辑

修复runcase关键字在接口用例中应用的Bug
This commit is contained in:
seagull 2021-04-19 21:03:38 +08:00
parent 6d0b9950ab
commit 9614164e92
9 changed files with 39 additions and 26 deletions

View File

@ -54,8 +54,9 @@ public class AndroidCaseExecution{
ProjectCaseSteps step = steps.get(i);
//处理步骤跳转语法
if(stepJumpNo!=0){
if(stepJumpNo!=0&&setcaseresult!=0){
if(stepJumpNo==i+1){
setcaseresult = 0;
LogUtil.APP.info("跳转至当前用例第{}步",i+1);
}else if(stepJumpNo>i+1){
LogUtil.APP.info("当前用例第{}步,跳过执行...",i+1);
@ -256,9 +257,9 @@ public class AndroidCaseExecution{
LogUtil.APP.info("预期结果中存在判断条件跳转步骤,处理前原始字符串:{}",expect);
String expectedTemp = expect.substring(Constants.IFFAIL_JUMP.length());
if(expectedTemp.contains(Constants.SYMLINK)){
expect = expectedTemp.substring(expectedTemp.indexOf(Constants.SYMLINK)+1);
expect = expectedTemp.substring(expectedTemp.indexOf(Constants.SYMLINK)+2);
try{
Integer stepJumpNo = Integer.getInteger(expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
Integer stepJumpNo = Integer.parseInt(expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
judgeResult.put("stepJumpNo",stepJumpNo);
}catch (NumberFormatException nfe){
LogUtil.APP.error("步骤跳转语法解析失败,步骤编号不是数字,请确认:{}",expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));

View File

@ -56,8 +56,9 @@ public class IosCaseExecution{
ProjectCaseSteps step = steps.get(i);
//处理步骤跳转语法
if(stepJumpNo!=0){
if(stepJumpNo!=0&&setcaseresult!=0){
if(stepJumpNo==i+1){
setcaseresult = 0;
LogUtil.APP.info("跳转至当前用例第{}步",i+1);
}else if(stepJumpNo>i+1){
LogUtil.APP.info("当前用例第{}步,跳过执行...",i+1);
@ -269,9 +270,9 @@ public class IosCaseExecution{
LogUtil.APP.info("预期结果中存在判断条件跳转步骤,处理前原始字符串:{}",expect);
String expectedTemp = expect.substring(Constants.IFFAIL_JUMP.length());
if(expectedTemp.contains(Constants.SYMLINK)){
expect = expectedTemp.substring(expectedTemp.indexOf(Constants.SYMLINK)+1);
expect = expectedTemp.substring(expectedTemp.indexOf(Constants.SYMLINK)+2);
try{
Integer stepJumpNo = Integer.getInteger(expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
Integer stepJumpNo = Integer.parseInt(expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
judgeResult.put("stepJumpNo",stepJumpNo);
}catch (NumberFormatException nfe){
LogUtil.APP.error("步骤跳转语法解析失败,步骤编号不是数字,请确认:{}",expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));

View File

@ -38,6 +38,7 @@ public class ChangString {
if (null == str) {
return null;
}
str = str.trim();
str = str.replace(""", "\"");
str = str.replace("'", "'");
// @@用来注释@的引用作用

View File

@ -68,8 +68,9 @@ public class ApiTestCaseDebug {
// 进入循环解析用例所有步骤
for (int i = 0; i < steps.size(); i++) {
//处理步骤跳转语法
if(stepJumpNo!=0){
if(stepJumpNo!=0&&setcaseresult!=0){
if(stepJumpNo==i+1){
setcaseresult = 0;
LogUtil.APP.info("跳转至当前用例第{}步",i+1);
}else if(stepJumpNo>i+1){
LogUtil.APP.info("当前用例第{}步,跳过执行...",i+1);
@ -128,9 +129,9 @@ public class ApiTestCaseDebug {
LogUtil.APP.info("预期结果中存在判断条件跳转步骤,处理前原始字符串:{}",expectedresults);
String expectedTemp = expectedresults.substring(Constants.IFFAIL_JUMP.length());
if(expectedTemp.contains(Constants.SYMLINK)){
expectedresults = expectedTemp.substring(expectedTemp.indexOf(Constants.SYMLINK)+1);
expectedresults = expectedTemp.substring(expectedTemp.indexOf(Constants.SYMLINK)+2);
try{
stepJumpNo = Integer.getInteger(expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
stepJumpNo = Integer.parseInt(expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
}catch (NumberFormatException nfe){
LogUtil.APP.error("步骤跳转语法解析失败,步骤编号不是数字,请确认:{}",expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
}

View File

@ -83,8 +83,9 @@ public class TestCaseExecution {
// 进入循环解析用例所有步骤
for (int i = 0; i < steps.size(); i++) {
//处理步骤跳转语法
if(stepJumpNo!=0){
if(stepJumpNo!=0&&setcaseresult!=0){
if(stepJumpNo==i+1){
setcaseresult = 0;
LogUtil.APP.info("跳转至当前用例第{}步",i+1);
}else if(stepJumpNo>i+1){
LogUtil.APP.info("当前用例第{}步,跳过执行...",i+1);
@ -233,7 +234,7 @@ public class TestCaseExecution {
Map<String, String> params;
ProjectCaseSteps step = steps.get(i);
//处理步骤跳转语法
if(stepJumpNo!=0){
if(stepJumpNo!=0&&setresult!=0){
if(stepJumpNo==i+1){
LogUtil.APP.info("跳转至当前用例第{}步",i+1);
}else if(stepJumpNo>i+1){
@ -389,9 +390,9 @@ public class TestCaseExecution {
LogUtil.APP.info("预期结果中存在判断条件跳转步骤,处理前原始字符串:{}",expectedresults);
String expectedTemp = expectedresults.substring(Constants.IFFAIL_JUMP.length());
if(expectedTemp.contains(Constants.SYMLINK)){
expectedresults = expectedTemp.substring(expectedTemp.indexOf(Constants.SYMLINK)+1);
expectedresults = expectedTemp.substring(expectedTemp.indexOf(Constants.SYMLINK)+2);
try{
Integer stepJumpNo = Integer.getInteger(expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
Integer stepJumpNo = Integer.parseInt(expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
judgeResult.put("stepJumpNo",stepJumpNo);
}catch (NumberFormatException nfe){
LogUtil.APP.error("步骤跳转语法解析失败,步骤编号不是数字,请确认:{}",expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));

View File

@ -74,8 +74,9 @@ public class ThreadForExecuteCase extends Thread {
caselog.insertTaskCaseExecute(taskid, projectId, caseId, caseSign, testcase.getCaseName(), 3);
for (int i = 0; i < steps.size(); i++) {
//处理步骤跳转语法
if(stepJumpNo!=0){
if(stepJumpNo!=0&&setcaseresult!=0){
if(stepJumpNo==i+1){
setcaseresult = 0;
LogUtil.APP.info("跳转至当前用例第{}步",i+1);
}else if(stepJumpNo>i+1){
LogUtil.APP.info("当前用例第{}步,跳过执行...",i+1);
@ -138,9 +139,9 @@ public class ThreadForExecuteCase extends Thread {
LogUtil.APP.info("预期结果中存在判断条件跳转步骤,处理前原始字符串:{}",expectedresults);
String expectedTemp = expectedresults.substring(Constants.IFFAIL_JUMP.length());
if(expectedTemp.contains(Constants.SYMLINK)){
expectedresults = expectedTemp.substring(expectedTemp.indexOf(Constants.SYMLINK)+1);
expectedresults = expectedTemp.substring(expectedTemp.indexOf(Constants.SYMLINK)+2);
try{
stepJumpNo = Integer.getInteger(expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
stepJumpNo = Integer.parseInt(expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
}catch (NumberFormatException nfe){
LogUtil.APP.error("步骤跳转语法解析失败,步骤编号不是数字,请确认:{}",expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
}

View File

@ -66,14 +66,18 @@ public class WebTestCaseDebug {
//进入循环解析用例所有步骤
for (int i = 0; i < steps.size(); i++) {
//处理步骤跳转语法
if(stepJumpNo!=0){
if(stepJumpNo!=0&&setcaseresult!=0){
if(stepJumpNo==i+1){
setcaseresult = 0;
PostServerApi.cPostDebugLog(userId, caseId, "INFO", "跳转至当前用例第"+(i+1)+"",0);
LogUtil.APP.info("跳转至当前用例第{}步",i+1);
}else if(stepJumpNo>i+1){
PostServerApi.cPostDebugLog(userId, caseId, "INFO", "当前用例第"+(i+1)+"步,跳过执行...",0);
LogUtil.APP.info("当前用例第{}步,跳过执行...",i+1);
continue;
}else{
LogUtil.APP.info("跳转步骤【{}】小于当前步骤【{}】,直接向下继续执行...",stepJumpNo,i+1);
PostServerApi.cPostDebugLog(userId, caseId, "INFO", "跳转步骤【"+stepJumpNo+"】小于当前步骤【"+(i+1)+"】,直接向下继续执行...",0);
LogUtil.APP.info("跳转步骤【{}】小于当前步骤【{}】,直接向下继续执行...",stepJumpNo,(i+1));
}
}
@ -125,16 +129,18 @@ public class WebTestCaseDebug {
if (null != expectedresults && !expectedresults.isEmpty()) {
//处理步骤跳转
if (expectedresults.length() > Constants.IFFAIL_JUMP.length() && expectedresults.startsWith(Constants.IFFAIL_JUMP)) {
PostServerApi.cPostDebugLog(userId, caseId, "INFO", "预期结果中存在判断条件跳转步骤,处理前原始字符串:"+expectedresults,0);
LogUtil.APP.info("预期结果中存在判断条件跳转步骤,处理前原始字符串:{}",expectedresults);
String expectedTemp = expectedresults.substring(Constants.IFFAIL_JUMP.length());
if(expectedTemp.contains(Constants.SYMLINK)){
expectedresults = expectedTemp.substring(expectedTemp.indexOf(Constants.SYMLINK)+1);
expectedresults = expectedTemp.substring(expectedTemp.indexOf(Constants.SYMLINK)+2);
try{
stepJumpNo = Integer.getInteger(expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
stepJumpNo = Integer.parseInt(expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
}catch (NumberFormatException nfe){
LogUtil.APP.error("步骤跳转语法解析失败,步骤编号不是数字,请确认:{}",expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
}
}else{
PostServerApi.cPostDebugLog(userId, caseId, "INFO", "处理预期结果条件判断失败,请确认预期结果语法结构:【"+Constants.IFFAIL_JUMP+">>预期结果】,原始预期结果值:"+expectedresults,0);
LogUtil.APP.warn("处理预期结果条件判断失败,请确认预期结果语法结构:【"+Constants.IFFAIL_JUMP+">>预期结果】,原始预期结果值:{}",expectedresults);
}
}
@ -252,4 +258,4 @@ public class WebTestCaseDebug {
}
}
}
}

View File

@ -38,10 +38,10 @@ public class InterfaceAnalyticCase{
String resultstr = step.getExpectedResult();
params.put("Action", step.getAction());
// 处理值传递
String packageName = ChangString.changparams(step.getStepPath().trim(), variable, "包路径");
String packageName = ChangString.changparams(step.getStepPath(), variable, "包路径");
params.put("PackageName", packageName);
// 处理值传递
String functionName = ChangString.changparams(step.getStepOperation().trim(), variable, "方法名");
String functionName = ChangString.changparams(step.getStepOperation(), variable, "方法名");
params.put("FunctionName", functionName);
String stepParams = replaceSpi(step.getStepParameters(),0);
String[] temp=stepParams.split("\\|",-1);

View File

@ -57,8 +57,9 @@ public class WebCaseExecution{
ProjectCaseSteps step = steps.get(i);
//处理步骤跳转语法
if(stepJumpNo!=0){
if(stepJumpNo!=0&&setcaseresult!=0){
if(stepJumpNo==i+1){
setcaseresult = 0;
LogUtil.APP.info("跳转至当前用例第{}步",i+1);
}else if(stepJumpNo>i+1){
LogUtil.APP.info("当前用例第{}步,跳过执行...",i+1);
@ -273,9 +274,9 @@ public class WebCaseExecution{
LogUtil.APP.info("预期结果中存在判断条件跳转步骤,处理前原始字符串:{}",expect);
String expectedTemp = expect.substring(Constants.IFFAIL_JUMP.length());
if(expectedTemp.contains(Constants.SYMLINK)){
expect = expectedTemp.substring(expectedTemp.indexOf(Constants.SYMLINK)+1);
expect = expectedTemp.substring(expectedTemp.indexOf(Constants.SYMLINK)+2);
try{
Integer stepJumpNo = Integer.getInteger(expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
Integer stepJumpNo = Integer.parseInt(expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));
judgeResult.put("stepJumpNo",stepJumpNo);
}catch (NumberFormatException nfe){
LogUtil.APP.error("步骤跳转语法解析失败,步骤编号不是数字,请确认:{}",expectedTemp.substring(0,expectedTemp.indexOf(Constants.SYMLINK)));