diff --git a/src/main/java/luckyclient/execution/httpinterface/ApiTestCaseDebug.java b/src/main/java/luckyclient/execution/httpinterface/ApiTestCaseDebug.java index 3af5666..d40ee3a 100644 --- a/src/main/java/luckyclient/execution/httpinterface/ApiTestCaseDebug.java +++ b/src/main/java/luckyclient/execution/httpinterface/ApiTestCaseDebug.java @@ -41,6 +41,8 @@ public class ApiTestCaseDebug { */ public static void oneCaseDebug(String testCaseExternalId) { Map variable = new HashMap<>(0); + // 初始化写用例结果以及日志模块 + serverOperation caselog = new serverOperation(); serverOperation.exetype=1; String packagename; String functionname; @@ -64,7 +66,7 @@ public class ApiTestCaseDebug { // 进入循环,解析用例所有步骤 for (int i = 0; i < steps.size(); i++) { Map casescript = InterfaceAnalyticCase.analyticCaseStep(testcase, steps.get(i), "888888", - null,variable); + caselog,variable); try { packagename = casescript.get("PackageName"); functionname = casescript.get("FunctionName"); @@ -97,8 +99,14 @@ public class ApiTestCaseDebug { // 调用动态方法,执行测试用例 try { LogUtil.APP.info("开始调用方法:{} .....",functionname); - testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, - steps.get(i).getStepType(), steps.get(i).getExtend()); + // 接口用例支持使用runcase关键字 + if ((null != functionname && "runcase".equals(functionname))) { + TestCaseExecution testCaseExecution=new TestCaseExecution(); + testnote = testCaseExecution.oneCaseExecuteForCase(getParameterValues[0].toString(), "888888", variable, caselog, null); + }else{ + testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, + steps.get(i).getStepType(), steps.get(i).getExtend()); + } testnote = ActionManageForSteps.actionManage(casescript.get("Action"), testnote); if (null != expectedresults && !expectedresults.isEmpty()) { LogUtil.APP.info("expectedResults=【{}】",expectedresults); diff --git a/src/main/java/luckyclient/execution/httpinterface/TestCaseExecution.java b/src/main/java/luckyclient/execution/httpinterface/TestCaseExecution.java index 1cd1f0b..8e26e6a 100644 --- a/src/main/java/luckyclient/execution/httpinterface/TestCaseExecution.java +++ b/src/main/java/luckyclient/execution/httpinterface/TestCaseExecution.java @@ -118,7 +118,13 @@ public class TestCaseExecution { try { LogUtil.APP.info("开始调用方法:{} .....",functionname); caselog.insertTaskCaseLog(taskid, testcase.getCaseId(), "开始调用方法:" + functionname + " .....", "info", String.valueOf(i + 1), ""); - testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getStepType(), steps.get(i).getExtend()); + // 接口用例支持使用runcase关键字 + if ((null != functionname && "runcase".equals(functionname))) { + TestCaseExecution testCaseExecution=new TestCaseExecution(); + testnote = testCaseExecution.oneCaseExecuteForCase(getParameterValues[0].toString(), taskid, RUNCASE_VARIABLE, caselog, null); + }else{ + testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getStepType(), steps.get(i).getExtend()); + } testnote = ActionManageForSteps.actionManage(casescript.get("Action"), testnote); // 判断结果 int stepresult = interfaceJudgeResult(testcase, steps.get(i), taskid, expectedresults, testnote, caselog); @@ -185,6 +191,10 @@ public class TestCaseExecution { String testnote = "初始化测试结果"; ProjectCase testcase = GetServerApi.cgetCaseBysign(testCaseExternalId); List pcplist = GetServerApi.cgetParamsByProjectid(String.valueOf(testcase.getProjectId())); + if(null==caselog){ + // 初始化写用例结果以及日志模块 + caselog = new serverOperation(); + } // 把公共参数加入到MAP中 for (ProjectCaseParams pcp : pcplist) { RUNCASE_VARIABLE.put(pcp.getParamsName(), pcp.getParamsValue()); @@ -312,7 +322,13 @@ public class TestCaseExecution { LogUtil.APP.info("二次解析用例过程完成,等待进行接口操作......"); caselog.insertTaskCaseLog(taskid, projectCase.getCaseId(), "包路径: " + packagename + "; 方法名: " + functionname, "info", String.valueOf(step.getStepSerialNumber()), ""); - result = InvokeMethod.callCase(packagename, functionname, getParameterValues, step.getStepType(), step.getExtend()); + // 接口用例支持使用runcase关键字 + if ((null != functionname && "runcase".equals(functionname))) { + TestCaseExecution testCaseExecution=new TestCaseExecution(); + result = testCaseExecution.oneCaseExecuteForCase(getParameterValues[0].toString(), taskid, RUNCASE_VARIABLE, caselog, null); + }else{ + result = InvokeMethod.callCase(packagename, functionname, getParameterValues, step.getStepType(), step.getExtend()); + } } } catch (Exception e) { LogUtil.APP.error("调用方法过程出错,方法名:{},请重新检查脚本方法名称以及参数!",functionname,e); diff --git a/src/main/java/luckyclient/execution/httpinterface/ThreadForExecuteCase.java b/src/main/java/luckyclient/execution/httpinterface/ThreadForExecuteCase.java index bdfd0f1..4c1309c 100644 --- a/src/main/java/luckyclient/execution/httpinterface/ThreadForExecuteCase.java +++ b/src/main/java/luckyclient/execution/httpinterface/ThreadForExecuteCase.java @@ -116,8 +116,8 @@ public class ThreadForExecuteCase extends Thread { testnote = testCaseExecution.oneCaseExecuteForCase(getParameterValues[0].toString(), taskid, variable, caselog, null); }else{ testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getStepType(), steps.get(i).getExtend()); - testnote = ActionManageForSteps.actionManage(casescript.get("Action"), testnote); } + testnote = ActionManageForSteps.actionManage(casescript.get("Action"), testnote); if (null != expectedresults && !expectedresults.isEmpty()) { LogUtil.APP.info("expectedResults=【{}】",expectedresults); diff --git a/src/main/java/luckyclient/execution/httpinterface/WebTestCaseDebug.java b/src/main/java/luckyclient/execution/httpinterface/WebTestCaseDebug.java index 32b2622..ab494d9 100644 --- a/src/main/java/luckyclient/execution/httpinterface/WebTestCaseDebug.java +++ b/src/main/java/luckyclient/execution/httpinterface/WebTestCaseDebug.java @@ -106,8 +106,8 @@ public class WebTestCaseDebug { testnote = testCaseExecution.oneCaseExecuteForCase(getParameterValues[0].toString(), "888888", variable, caselog, null); }else{ testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getStepType(), steps.get(i).getExtend()); - testnote = ActionManageForSteps.actionManage(casescript.get("Action"), testnote); } + testnote = ActionManageForSteps.actionManage(casescript.get("Action"), testnote); if (null != expectedresults && !expectedresults.isEmpty()) { // 赋值传参