parent
2e15eab6d2
commit
3acc93e138
|
@ -71,6 +71,7 @@ public class BatchCaseExecute extends TestControl {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,5 +68,6 @@ public class OneCaseExecute extends TestControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
System.exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ public class RunAutomationTest extends TestControl {
|
||||||
} else if (task.getTestJob().getExtype() == 2) {
|
} else if (task.getTestJob().getExtype() == 2) {
|
||||||
AppTestControl.taskExecutionPlan(taskid, task);
|
AppTestControl.taskExecutionPlan(taskid, task);
|
||||||
}
|
}
|
||||||
|
System.exit(0);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -26,5 +26,6 @@ public class WebDebugExecute extends TestControl{
|
||||||
String sign = args[0];
|
String sign = args[0];
|
||||||
String executor = args[1];
|
String executor = args[1];
|
||||||
WebTestCaseDebug.oneCaseDebug(sign,executor);
|
WebTestCaseDebug.oneCaseDebug(sign,executor);
|
||||||
|
System.exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,16 +42,15 @@ public class TestCaseExecution {
|
||||||
protected static final String ASSIGNMENT_SIGN = "$=";
|
protected static final String ASSIGNMENT_SIGN = "$=";
|
||||||
protected static final String FUZZY_MATCHING_SIGN = "%=";
|
protected static final String FUZZY_MATCHING_SIGN = "%=";
|
||||||
protected static final String REGULAR_MATCHING_SIGN = "~=";
|
protected static final String REGULAR_MATCHING_SIGN = "~=";
|
||||||
|
private static Map<String, String> VARIABLE = new HashMap<String, String>(0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param projectname 项目名
|
* @param projectname 项目名
|
||||||
* @param testCaseExternalId 用例编号
|
* @param testCaseExternalId 用例编号
|
||||||
* @param version 用例版本号
|
* @param version 用例版本号
|
||||||
* 用于单条用例调试,并通过日志框架写日志到UTP上,用做UTP上单条用例运行
|
* 用于单条用例调试,并通过日志框架写日志到UTP上,用做UTP上单条用例运行
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static void oneCaseExecuteForTast(String projectname, String testCaseExternalId, int version, String taskid) {
|
public static void oneCaseExecuteForTast(String projectname, String testCaseExternalId, int version, String taskid) {
|
||||||
Map<String, String> variable = new HashMap<String, String>(0);
|
|
||||||
TestControl.TASKID = taskid;
|
TestControl.TASKID = taskid;
|
||||||
DbLink.exetype = 0;
|
DbLink.exetype = 0;
|
||||||
// 初始化写用例结果以及日志模块
|
// 初始化写用例结果以及日志模块
|
||||||
|
@ -69,13 +68,13 @@ public class TestCaseExecution {
|
||||||
List<PublicCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcaseob.getProjectid()));
|
List<PublicCaseParams> pcplist = GetServerAPI.cgetParamsByProjectid(String.valueOf(testcaseob.getProjectid()));
|
||||||
// 把公共参数加入到MAP中
|
// 把公共参数加入到MAP中
|
||||||
for (PublicCaseParams pcp : pcplist) {
|
for (PublicCaseParams pcp : pcplist) {
|
||||||
variable.put(pcp.getParamsname(), pcp.getParamsvalue());
|
VARIABLE.put(pcp.getParamsname(), pcp.getParamsvalue());
|
||||||
}
|
}
|
||||||
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
List<ProjectCasesteps> steps = GetServerAPI.getStepsbycaseid(testcaseob.getId());
|
||||||
if (steps.size() == 0) {
|
if (steps.size() == 0) {
|
||||||
setcaseresult = 2;
|
setcaseresult = 2;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例中未找到步骤,请检查!");
|
luckyclient.publicclass.LogUtil.APP.error("用例中未找到步骤,请检查!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "用例中未找到步骤,请检查!", "error", "1");
|
caselog.caseLogDetail(taskid, testCaseExternalId, "用例中未找到步骤,请检查!", "error", "1", "");
|
||||||
testnote = "用例中未找到步骤,请检查!";
|
testnote = "用例中未找到步骤,请检查!";
|
||||||
}
|
}
|
||||||
// 进入循环,解析用例所有步骤
|
// 进入循环,解析用例所有步骤
|
||||||
|
@ -83,9 +82,9 @@ public class TestCaseExecution {
|
||||||
Map<String, String> casescript = InterfaceAnalyticCase.analyticCaseStep(testcaseob, steps.get(i), taskid, caselog);
|
Map<String, String> casescript = InterfaceAnalyticCase.analyticCaseStep(testcaseob, steps.get(i), taskid, caselog);
|
||||||
try {
|
try {
|
||||||
packagename = casescript.get("PackageName");
|
packagename = casescript.get("PackageName");
|
||||||
packagename = ChangString.changparams(packagename, variable, "包路径");
|
packagename = ChangString.changparams(packagename, VARIABLE, "包路径");
|
||||||
functionname = casescript.get("FunctionName");
|
functionname = casescript.get("FunctionName");
|
||||||
functionname = ChangString.changparams(functionname, variable, "方法名");
|
functionname = ChangString.changparams(functionname, VARIABLE, "方法名");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
k = 0;
|
k = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "解析包名或是方法名失败,请检查!");
|
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + "解析包名或是方法名失败,请检查!");
|
||||||
|
@ -100,7 +99,7 @@ public class TestCaseExecution {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
expectedresults = casescript.get("ExpectedResults");
|
expectedresults = casescript.get("ExpectedResults");
|
||||||
expectedresults = ChangString.changparams(expectedresults, variable, "预期结果");
|
expectedresults = ChangString.changparams(expectedresults, VARIABLE, "预期结果");
|
||||||
// 判断方法是否带参数
|
// 判断方法是否带参数
|
||||||
if (casescript.size() > 4) {
|
if (casescript.size() > 4) {
|
||||||
// 获取传入参数,放入对象中,初始化参数对象个数
|
// 获取传入参数,放入对象中,初始化参数对象个数
|
||||||
|
@ -112,7 +111,7 @@ public class TestCaseExecution {
|
||||||
}
|
}
|
||||||
|
|
||||||
String parameterValues = casescript.get("FunctionParams" + (j + 1));
|
String parameterValues = casescript.get("FunctionParams" + (j + 1));
|
||||||
parameterValues = ChangString.changparams(parameterValues, variable, "用例参数");
|
parameterValues = ChangString.changparams(parameterValues, VARIABLE, "用例参数");
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues);
|
||||||
caselog.caseLogDetail(taskid, testcaseob.getSign(), "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues, "info", String.valueOf(i + 1), "");
|
caselog.caseLogDetail(taskid, testcaseob.getSign(), "解析包名:" + packagename + " 方法名:" + functionname + " 第" + (j + 1) + "个参数:" + parameterValues, "info", String.valueOf(i + 1), "");
|
||||||
getParameterValues[j] = parameterValues;
|
getParameterValues[j] = parameterValues;
|
||||||
|
@ -123,77 +122,31 @@ public class TestCaseExecution {
|
||||||
// 调用动态方法,执行测试用例
|
// 调用动态方法,执行测试用例
|
||||||
try {
|
try {
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:" + functionname + " .....");
|
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:" + functionname + " .....");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "开始调用方法:" + functionname + " .....", "info", String.valueOf(i + 1));
|
caselog.caseLogDetail(taskid, testCaseExternalId, "开始调用方法:" + functionname + " .....", "info", String.valueOf(i + 1), "");
|
||||||
|
|
||||||
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getSteptype(), steps.get(i).getAction());
|
testnote = InvokeMethod.callCase(packagename, functionname, getParameterValues, steps.get(i).getSteptype(), steps.get(i).getAction());
|
||||||
|
|
||||||
if (null != expectedresults && !expectedresults.isEmpty()) {
|
// 判断结果
|
||||||
luckyclient.publicclass.LogUtil.APP.info("expectedResults=【" + expectedresults + "】");
|
int stepresult = interfaceJudgeResult(testcaseob, steps.get(i), taskid, expectedresults, testnote, caselog);
|
||||||
// 赋值传参
|
// 失败,并且不在继续,直接终止
|
||||||
if (expectedresults.length() > ASSIGNMENT_SIGN.length() && expectedresults.startsWith(ASSIGNMENT_SIGN)) {
|
if (0 != stepresult) {
|
||||||
variable.put(expectedresults.substring(ASSIGNMENT_SIGN.length()), testnote);
|
setcaseresult = stepresult;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】");
|
if (testcaseob.getFailcontinue() == 0) {
|
||||||
}
|
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+steps.get(i).getStepnum()+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
||||||
// 模糊匹配
|
break;
|
||||||
else if (expectedresults.length() > FUZZY_MATCHING_SIGN.length() && expectedresults.startsWith(FUZZY_MATCHING_SIGN)) {
|
} else {
|
||||||
if (testnote.contains(expectedresults.substring(FUZZY_MATCHING_SIGN.length()))) {
|
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+steps.get(i).getStepnum()+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,模糊匹配预期结果成功!执行结果:" + testnote);
|
|
||||||
} else {
|
|
||||||
setcaseresult = 1;
|
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
|
||||||
testnote = "用例第" + (i + 1) + "步,模糊匹配预期结果失败!";
|
|
||||||
if (testcaseob.getFailcontinue() == 0) {
|
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 正则匹配
|
|
||||||
else if (expectedresults.length() > REGULAR_MATCHING_SIGN.length() && expectedresults.startsWith(REGULAR_MATCHING_SIGN)) {
|
|
||||||
Pattern pattern = Pattern.compile(expectedresults.substring(REGULAR_MATCHING_SIGN.length()));
|
|
||||||
Matcher matcher = pattern.matcher(testnote);
|
|
||||||
if (matcher.find()) {
|
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,正则匹配预期结果成功!执行结果:" + testnote);
|
|
||||||
} else {
|
|
||||||
setcaseresult = 1;
|
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
|
||||||
testnote = "用例第" + (i + 1) + "步,正则匹配预期结果失败!";
|
|
||||||
if (testcaseob.getFailcontinue() == 0) {
|
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 完全相等
|
|
||||||
else {
|
|
||||||
if (expectedresults.equals(testnote)) {
|
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,精确匹配预期结果成功!执行结果:" + testnote);
|
|
||||||
} else {
|
|
||||||
setcaseresult = 1;
|
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcaseob.getSign() + " 第" + (i + 1) + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote);
|
|
||||||
testnote = "用例第" + (i + 1) + "步,精确匹配预期结果失败!";
|
|
||||||
if (testcaseob.getFailcontinue() == 0) {
|
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,中断本条用例后续步骤执行,进入到下一条用例执行中......");
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例【"+testcaseob.getSign()+"】第【"+(i + 1)+"】步骤执行失败,继续本条用例后续步骤执行,进入下个步骤执行中......");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取步骤间等待时间
|
// 获取步骤间等待时间
|
||||||
int waitsec = Integer.parseInt(casescript.get("StepWait"));
|
int waitsec = Integer.parseInt(casescript.get("StepWait"));
|
||||||
if (waitsec > 0) {
|
if (waitsec > 0) {
|
||||||
Thread.sleep(waitsec * 1000);
|
Thread.sleep(waitsec * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error("调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!");
|
luckyclient.publicclass.LogUtil.ERROR.error("调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!", "error", String.valueOf(i + 1));
|
caselog.caseLogDetail(taskid, testCaseExternalId, "调用方法过程出错,方法名:" + functionname + " 请重新检查脚本方法名称以及参数!", "error", String.valueOf(i + 1), "");
|
||||||
luckyclient.publicclass.LogUtil.ERROR.error(e, e);
|
luckyclient.publicclass.LogUtil.ERROR.error(e, e);
|
||||||
testnote = "CallCase调用出错!";
|
testnote = "CallCase调用出错!";
|
||||||
setcaseresult = 1;
|
setcaseresult = 1;
|
||||||
|
@ -206,24 +159,25 @@ public class TestCaseExecution {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
variable.clear(); // 清空传参MAP
|
|
||||||
|
VARIABLE.clear(); // 清空传参MAP
|
||||||
// 如果调用方法过程中未出错,进入设置测试结果流程
|
// 如果调用方法过程中未出错,进入设置测试结果流程
|
||||||
if (!testnote.contains("CallCase调用出错!") && !testnote.contains("解析出错啦!")) {
|
if (!testnote.contains("CallCase调用出错!") && !testnote.contains("解析出错啦!")) {
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "解析成功,并成功调用用例中方法,请继续查看执行结果!", "info", "SETCASERESULT...");
|
caselog.caseLogDetail(taskid, testCaseExternalId, "解析成功,并成功调用用例中方法,请继续查看执行结果!", "info", "SETCASERESULT...", "");
|
||||||
caselog.updateCaseDetail(taskid, testCaseExternalId, setcaseresult);
|
caselog.updateCaseDetail(taskid, testCaseExternalId, setcaseresult);
|
||||||
} else {
|
} else {
|
||||||
setcaseresult = 1;
|
setcaseresult = 1;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "解析或是调用步骤中的方法出错!");
|
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "解析或是调用步骤中的方法出错!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "解析或是调用步骤中的方法出错!", "error", "SETCASERESULT...");
|
caselog.caseLogDetail(taskid, testCaseExternalId, "解析或是调用步骤中的方法出错!", "error", "SETCASERESULT...", "");
|
||||||
caselog.updateCaseDetail(taskid, testCaseExternalId, 2);
|
caselog.updateCaseDetail(taskid, testCaseExternalId, 2);
|
||||||
}
|
}
|
||||||
if (0 == setcaseresult) {
|
if (0 == setcaseresult) {
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "步骤全部执行成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例 " + testCaseExternalId + "步骤全部执行成功!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "步骤全部执行成功!", "info", "EXECUTECASESUC...");
|
caselog.caseLogDetail(taskid, testCaseExternalId, "步骤全部执行成功!", "info", "EXECUTECASESUC...", "");
|
||||||
} else {
|
} else {
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "在执行过程中失败,请检查日志!");
|
luckyclient.publicclass.LogUtil.APP.error("用例 " + testCaseExternalId + "在执行过程中失败,请检查日志!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, taskid, "在执行过程中失败,请检查日志!", "error", "EXECUTECASESUC...");
|
caselog.caseLogDetail(taskid, testCaseExternalId, "在执行过程中失败,请检查日志!", "error", "EXECUTECASESUC...", "");
|
||||||
}
|
}
|
||||||
LogOperation.updateTastdetail(taskid, 0);
|
LogOperation.updateTastdetail(taskid, 0);
|
||||||
}
|
}
|
||||||
|
@ -446,6 +400,8 @@ public class TestCaseExecution {
|
||||||
|
|
||||||
} else{
|
} else{
|
||||||
result = runStep(params, variable, taskid, testcaseob.getSign(), step, caselog);
|
result = runStep(params, variable, taskid, testcaseob.getSign(), step, caselog);
|
||||||
|
// 判断结果
|
||||||
|
setresult = interfaceJudgeResult(testcaseob, step, taskid, expectedresults, testnote, caselog);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != setresult){
|
if (0 != setresult){
|
||||||
|
@ -523,4 +479,63 @@ public class TestCaseExecution {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int interfaceJudgeResult(ProjectCase testcase, ProjectCasesteps step, String taskid, String expectedresults, String testnote, LogOperation caselog){
|
||||||
|
int setresult = 0;
|
||||||
|
try{
|
||||||
|
if (null != expectedresults && !expectedresults.isEmpty()) {
|
||||||
|
luckyclient.publicclass.LogUtil.APP.info("expectedResults=【" + expectedresults + "】");
|
||||||
|
// 赋值传参
|
||||||
|
if (expectedresults.length() > ASSIGNMENT_SIGN.length() && expectedresults.startsWith(ASSIGNMENT_SIGN)) {
|
||||||
|
VARIABLE.put(expectedresults.substring(ASSIGNMENT_SIGN.length()), testnote);
|
||||||
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】");
|
||||||
|
caselog.caseLogDetail(taskid, testcase.getSign(), "将测试结果【" + testnote + "】赋值给变量【" + expectedresults.substring(ASSIGNMENT_SIGN.length()) + "】", "info", String.valueOf(step.getStepnum()), "");
|
||||||
|
}
|
||||||
|
// 模糊匹配
|
||||||
|
else if (expectedresults.length() > FUZZY_MATCHING_SIGN.length() && expectedresults.startsWith(FUZZY_MATCHING_SIGN)) {
|
||||||
|
if (testnote.contains(expectedresults.substring(FUZZY_MATCHING_SIGN.length()))) {
|
||||||
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,模糊匹配预期结果成功!执行结果:" + testnote);
|
||||||
|
caselog.caseLogDetail(taskid, testcase.getSign(), "模糊匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(step.getStepnum()), "");
|
||||||
|
} else {
|
||||||
|
setresult = 1;
|
||||||
|
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||||
|
caselog.caseLogDetail(taskid, testcase.getSign(), "模糊匹配预期结果失败!预期结果:" + expectedresults.substring(FUZZY_MATCHING_SIGN.length()) + ",测试结果:" + testnote, "error", String.valueOf(step.getStepnum()), "");
|
||||||
|
testnote = "用例第" + step.getStepnum() + "步,模糊匹配预期结果失败!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 正则匹配
|
||||||
|
else if (expectedresults.length() > REGULAR_MATCHING_SIGN.length() && expectedresults.startsWith(REGULAR_MATCHING_SIGN)) {
|
||||||
|
Pattern pattern = Pattern.compile(expectedresults.substring(REGULAR_MATCHING_SIGN.length()));
|
||||||
|
Matcher matcher = pattern.matcher(testnote);
|
||||||
|
if (matcher.find()) {
|
||||||
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,正则匹配预期结果成功!执行结果:" + testnote);
|
||||||
|
caselog.caseLogDetail(taskid, testcase.getSign(), "正则匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(step.getStepnum()), "");
|
||||||
|
} else {
|
||||||
|
setresult = 1;
|
||||||
|
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote);
|
||||||
|
caselog.caseLogDetail(taskid, testcase.getSign(), "正则匹配预期结果失败!预期结果:" + expectedresults.substring(REGULAR_MATCHING_SIGN.length()) + ",测试结果:" + testnote, "error", String.valueOf(step.getStepnum()), "");
|
||||||
|
testnote = "用例第" + step.getStepnum() + "步,正则匹配预期结果失败!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 完全相等
|
||||||
|
else {
|
||||||
|
if (expectedresults.equals(testnote)) {
|
||||||
|
luckyclient.publicclass.LogUtil.APP.info("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,精确匹配预期结果成功!执行结果:" + testnote);
|
||||||
|
caselog.caseLogDetail(taskid, testcase.getSign(), "精确匹配预期结果成功!执行结果:" + testnote, "info", String.valueOf(step.getStepnum()), "");
|
||||||
|
} else {
|
||||||
|
setresult = 1;
|
||||||
|
luckyclient.publicclass.LogUtil.APP.error("用例:" + testcase.getSign() + " 第" + step.getStepnum() + "步,精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote);
|
||||||
|
caselog.caseLogDetail(taskid, testcase.getSign(), "精确匹配预期结果失败!预期结果:" + expectedresults + ",测试结果:" + testnote, "error", String.valueOf(step.getStepnum()), "");
|
||||||
|
testnote = "用例第" + step.getStepnum() + "步,精确匹配预期结果失败!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
setresult = 2;
|
||||||
|
return setresult;
|
||||||
|
}
|
||||||
|
return setresult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,9 @@ public class TestLinkCaseExecution{
|
||||||
* 用于在testlink上配置好用例参数后,做单条用例调试,并通过日志框架写日志到UTP上,用做UTP上单条用例运行
|
* 用于在testlink上配置好用例参数后,做单条用例调试,并通过日志框架写日志到UTP上,用做UTP上单条用例运行
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
||||||
public static void oneCaseExecuteForTast(String projectname,String testCaseExternalId,int version,String tastid){
|
public static void oneCaseExecuteForTast(String projectname,String testCaseExternalId,int version,String taskid){
|
||||||
Map<String,String> variable = new HashMap<String,String>(0);
|
Map<String,String> variable = new HashMap<String,String>(0);
|
||||||
TestControl.TASKID = tastid;
|
TestControl.TASKID = taskid;
|
||||||
DbLink.exetype = 0;
|
DbLink.exetype = 0;
|
||||||
LogOperation caselog = new LogOperation();
|
LogOperation caselog = new LogOperation();
|
||||||
String packagename =null;
|
String packagename =null;
|
||||||
|
@ -45,12 +45,12 @@ public class TestLinkCaseExecution{
|
||||||
Object[] getParameterValues = null;
|
Object[] getParameterValues = null;
|
||||||
String testnote = null;
|
String testnote = null;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
LogOperation.deleteCaseLogDetail(testCaseExternalId, tastid);
|
LogOperation.deleteCaseLogDetail(testCaseExternalId, taskid);
|
||||||
TestCase testcaseob = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
TestCase testcaseob = TestCaseApi.getTestCaseByExternalId(testCaseExternalId, version);
|
||||||
if(testcaseob.getExecutionType()==ExecutionType.AUTOMATED){
|
if(testcaseob.getExecutionType()==ExecutionType.AUTOMATED){
|
||||||
//进入循环,解析用例所有步骤
|
//进入循环,解析用例所有步骤
|
||||||
for(int i=0;i<testcaseob.getSteps().size();i++){
|
for(int i=0;i<testcaseob.getSteps().size();i++){
|
||||||
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.analyticCaseStep(testcaseob, i+1,tastid,caselog);
|
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.analyticCaseStep(testcaseob, i+1,taskid,caselog);
|
||||||
packagename = casescript.get("PackageName").toString();
|
packagename = casescript.get("PackageName").toString();
|
||||||
functionname = casescript.get("FunctionName").toString();
|
functionname = casescript.get("FunctionName").toString();
|
||||||
//用例名称解析出现异常或是单个步骤参数解析异常
|
//用例名称解析出现异常或是单个步骤参数解析异常
|
||||||
|
@ -100,7 +100,7 @@ public class TestLinkCaseExecution{
|
||||||
casescript.get("FunctionParams"+(j+1)).indexOf(uservariable1)-1);
|
casescript.get("FunctionParams"+(j+1)).indexOf(uservariable1)-1);
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("你好像在一个参数中引用了超过3个以上的变量哦!我处理不过来啦!");
|
luckyclient.publicclass.LogUtil.APP.error("你好像在一个参数中引用了超过3个以上的变量哦!我处理不过来啦!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "你好像在一个参数中引用了超过2个以上的变量哦!我处理不过来啦!", "error",String.valueOf(i+1));
|
caselog.caseLogDetail(taskid, testCaseExternalId, "你好像在一个参数中引用了超过2个以上的变量哦!我处理不过来啦!", "error",String.valueOf(i+1), "");
|
||||||
}
|
}
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
Iterator keys = variable.keySet().iterator();
|
Iterator keys = variable.keySet().iterator();
|
||||||
|
@ -154,14 +154,14 @@ public class TestLinkCaseExecution{
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+parameterValues);
|
+" 第"+(j+1)+"个参数:"+parameterValues);
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "解析包名:"+packagename+" 方法名:"+functionname
|
caselog.caseLogDetail(taskid, testCaseExternalId, "解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+parameterValues, "info",String.valueOf(i+1));
|
+" 第"+(j+1)+"个参数:"+parameterValues, "info",String.valueOf(i+1), "");
|
||||||
getParameterValues[j] = parameterValues;
|
getParameterValues[j] = parameterValues;
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:"+uservariable+",第"
|
luckyclient.publicclass.LogUtil.APP.error("没有找到你要的变量哦,再找下吧!第一个变量名称是:"+uservariable+",第"
|
||||||
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2);
|
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2);
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "没有找到你要的变量哦,再找下吧!第二变量名称是:"+uservariable+",第"
|
caselog.caseLogDetail(taskid, testCaseExternalId, "没有找到你要的变量哦,再找下吧!第二变量名称是:"+uservariable+",第"
|
||||||
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2, "error",String.valueOf(i+1));
|
+ "二个变量名称是:"+uservariable1+",第三个变量名称是:"+uservariable2, "error",String.valueOf(i+1), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
@ -173,8 +173,8 @@ public class TestLinkCaseExecution{
|
||||||
}
|
}
|
||||||
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
luckyclient.publicclass.LogUtil.APP.info("解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+parameterValues1);
|
+" 第"+(j+1)+"个参数:"+parameterValues1);
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "解析包名:"+packagename+" 方法名:"+functionname
|
caselog.caseLogDetail(taskid, testCaseExternalId, "解析包名:"+packagename+" 方法名:"+functionname
|
||||||
+" 第"+(j+1)+"个参数:"+parameterValues1, "info",String.valueOf(i+1));
|
+" 第"+(j+1)+"个参数:"+parameterValues1, "info",String.valueOf(i+1), "");
|
||||||
getParameterValues[j] = parameterValues1;
|
getParameterValues[j] = parameterValues1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ public class TestLinkCaseExecution{
|
||||||
//调用动态方法,执行测试用例
|
//调用动态方法,执行测试用例
|
||||||
try{
|
try{
|
||||||
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:"+functionname+" .....");
|
luckyclient.publicclass.LogUtil.APP.info("开始调用方法:"+functionname+" .....");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "开始调用方法:"+functionname+" .....", "info",String.valueOf(i+1));
|
caselog.caseLogDetail(taskid, testCaseExternalId, "开始调用方法:"+functionname+" .....", "info",String.valueOf(i+1), "");
|
||||||
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){
|
if(expectedresults.length()>2 && expectedresults.substring(0, 2).indexOf("$=")>-1){
|
||||||
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
String expectedResultVariable = casescript.get("ExpectedResults").toString().substring(2);
|
||||||
String temptestnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
String temptestnote = InvokeMethod.callCase(packagename,functionname,getParameterValues,0,"");
|
||||||
|
@ -194,11 +194,11 @@ public class TestLinkCaseExecution{
|
||||||
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
if(testnote.indexOf(expectedresults.substring(2))>-1){
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "用例执行结果是:"+testnote+",与预期结果匹配成功!", "info",String.valueOf(i+1));
|
caselog.caseLogDetail(taskid, testCaseExternalId, "用例执行结果是:"+testnote+",与预期结果匹配成功!", "info",String.valueOf(i+1), "");
|
||||||
}else{
|
}else{
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
luckyclient.publicclass.LogUtil.APP.error("用例第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:"+testnote, "error",String.valueOf(i+1));
|
caselog.caseLogDetail(taskid, testCaseExternalId, "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:"+testnote, "error",String.valueOf(i+1), "");
|
||||||
luckyclient.publicclass.LogUtil.APP.error("预期结果:"+expectedresults+" 测试结果:"+testnote);
|
luckyclient.publicclass.LogUtil.APP.error("预期结果:"+expectedresults+" 测试结果:"+testnote);
|
||||||
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!";
|
testnote = "用例第"+(i+1)+"步执行结果与预期结果匹配失败!";
|
||||||
break; //某一步骤失败后,此条用例置为失败退出
|
break; //某一步骤失败后,此条用例置为失败退出
|
||||||
|
@ -208,12 +208,12 @@ public class TestLinkCaseExecution{
|
||||||
if(expectedresults.equals(testnote)){
|
if(expectedresults.equals(testnote)){
|
||||||
setresult = 0;
|
setresult = 0;
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例执行结果是:"+testnote+",与预期结果匹配成功!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "用例执行结果是:"+testnote+",与预期结果匹配成功!", "info",String.valueOf(i+1));
|
caselog.caseLogDetail(taskid, testCaseExternalId, "用例执行结果是:"+testnote+",与预期结果匹配成功!", "info",String.valueOf(i+1), "");
|
||||||
}else{
|
}else{
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
luckyclient.publicclass.LogUtil.APP.error("用例第"+(i+1)+"步执行结果与预期结果匹配失败!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"
|
caselog.caseLogDetail(taskid, testCaseExternalId, "用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"
|
||||||
+expectedresults+" 测试结果:"+testnote, "error",String.valueOf(i+1));
|
+expectedresults+" 测试结果:"+testnote, "error",String.valueOf(i+1), "");
|
||||||
luckyclient.publicclass.LogUtil.APP.error("预期结果:"+expectedresults+" 测试结果:"+testnote);
|
luckyclient.publicclass.LogUtil.APP.error("预期结果:"+expectedresults+" 测试结果:"+testnote);
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
stringBuilder.append("用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:");
|
stringBuilder.append("用例第"+(i+1)+"步执行结果与预期结果匹配失败!预期结果:"+expectedresults+" 测试结果:");
|
||||||
|
@ -228,7 +228,7 @@ public class TestLinkCaseExecution{
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
luckyclient.publicclass.LogUtil.APP.error("调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!");
|
luckyclient.publicclass.LogUtil.APP.error("调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!", "error",String.valueOf(i+1));
|
caselog.caseLogDetail(taskid, testCaseExternalId, "调用方法过程出错,方法名:"+functionname+" 请重新检查脚本方法名称以及参数!", "error",String.valueOf(i+1), "");
|
||||||
luckyclient.publicclass.LogUtil.APP.error(e,e);
|
luckyclient.publicclass.LogUtil.APP.error(e,e);
|
||||||
testnote = "CallCase调用出错!";
|
testnote = "CallCase调用出错!";
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
|
@ -240,28 +240,28 @@ public class TestLinkCaseExecution{
|
||||||
//如果调用方法过程中未出错,进入设置测试结果流程
|
//如果调用方法过程中未出错,进入设置测试结果流程
|
||||||
if(testnote.indexOf("CallCase调用出错!")<=-1&&testnote.indexOf("解析出错啦!")<=-1){
|
if(testnote.indexOf("CallCase调用出错!")<=-1&&testnote.indexOf("解析出错啦!")<=-1){
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例 "+testCaseExternalId+"解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
luckyclient.publicclass.LogUtil.APP.info("用例 "+testCaseExternalId+"解析成功,并成功调用用例中方法,请继续查看执行结果!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "解析成功,并成功调用用例中方法,请继续查看执行结果!", "info","SETCASERESULT...");
|
caselog.caseLogDetail(taskid, testCaseExternalId, "解析成功,并成功调用用例中方法,请继续查看执行结果!", "info","SETCASERESULT...", "");
|
||||||
//TCResult = TestCaseApi.setTCResult(projectname,testCaseExternalId, testnote, version,setresult);
|
//TCResult = TestCaseApi.setTCResult(projectname,testCaseExternalId, testnote, version,setresult);
|
||||||
caselog.updateCaseDetail(tastid, testCaseExternalId, setresult);
|
caselog.updateCaseDetail(taskid, testCaseExternalId, setresult);
|
||||||
}else{
|
}else{
|
||||||
setresult = 1;
|
setresult = 1;
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"解析或是调用步骤中的方法出错!");
|
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"解析或是调用步骤中的方法出错!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "解析或是调用步骤中的方法出错!", "error","SETCASERESULT...");
|
caselog.caseLogDetail(taskid, testCaseExternalId, "解析或是调用步骤中的方法出错!", "error","SETCASERESULT...", "");
|
||||||
// TCResult = TestCaseApi.setTCResult(projectname,testCaseExternalId, testnote, version,2);
|
// TCResult = TestCaseApi.setTCResult(projectname,testCaseExternalId, testnote, version,2);
|
||||||
caselog.updateCaseDetail(tastid, testCaseExternalId, 2);
|
caselog.updateCaseDetail(taskid, testCaseExternalId, 2);
|
||||||
}
|
}
|
||||||
if(0==setresult){
|
if(0==setresult){
|
||||||
luckyclient.publicclass.LogUtil.APP.info("用例 "+testCaseExternalId+"步骤全部执行成功!");
|
luckyclient.publicclass.LogUtil.APP.info("用例 "+testCaseExternalId+"步骤全部执行成功!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "步骤全部执行成功!", "info","EXECUTECASESUC...");
|
caselog.caseLogDetail(taskid, testCaseExternalId, "步骤全部执行成功!", "info","EXECUTECASESUC...", "");
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"在执行过程中失败,请检查日志!");
|
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"在执行过程中失败,请检查日志!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "在执行过程中失败,请检查日志!", "error","EXECUTECASESUC...");
|
caselog.caseLogDetail(taskid, testCaseExternalId, "在执行过程中失败,请检查日志!", "error","EXECUTECASESUC...", "");
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"不是一个自动化的用例哦!先去把它设置一下吧!");
|
luckyclient.publicclass.LogUtil.APP.error("用例 "+testCaseExternalId+"不是一个自动化的用例哦!先去把它设置一下吧!");
|
||||||
LogOperation.updateCaseLogDetail(testCaseExternalId, tastid, "不是一个自动化的用例哦!先去把它设置一下吧!", "error","EXECUTECASEFAIL...");
|
caselog.caseLogDetail(taskid, testCaseExternalId, "不是一个自动化的用例哦!先去把它设置一下吧!", "error","EXECUTECASEFAIL...", "");
|
||||||
}
|
}
|
||||||
LogOperation.updateTastdetail(tastid, 0);
|
LogOperation.updateTastdetail(taskid, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ public class TestLinkCaseExecution{
|
||||||
* @param 用例版本号
|
* @param 用例版本号
|
||||||
* 用于在UI的测试过程中,需要调用接口的测试用例
|
* 用于在UI的测试过程中,需要调用接口的测试用例
|
||||||
*/
|
*/
|
||||||
protected static String oneCaseExecuteForWebDriver(String testCaseExternalId,int version,String tastid,LogOperation caselog){
|
protected static String oneCaseExecuteForWebDriver(String testCaseExternalId,int version,String taskid,LogOperation caselog){
|
||||||
Map<String,String> variable = new HashMap<String,String>(0);
|
Map<String,String> variable = new HashMap<String,String>(0);
|
||||||
String packagename =null;
|
String packagename =null;
|
||||||
String functionname = null;
|
String functionname = null;
|
||||||
|
@ -284,7 +284,7 @@ public class TestLinkCaseExecution{
|
||||||
if(testcaseob.getExecutionType()==ExecutionType.AUTOMATED){
|
if(testcaseob.getExecutionType()==ExecutionType.AUTOMATED){
|
||||||
//进入循环,解析用例所有步骤
|
//进入循环,解析用例所有步骤
|
||||||
for(int i=0;i<testcaseob.getSteps().size();i++){
|
for(int i=0;i<testcaseob.getSteps().size();i++){
|
||||||
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.analyticCaseStep(testcaseob, i+1,tastid,caselog);
|
Map<String,String> casescript = InterfaceAnalyticTestLinkCase.analyticCaseStep(testcaseob, i+1,taskid,caselog);
|
||||||
packagename = casescript.get("PackageName").toString();
|
packagename = casescript.get("PackageName").toString();
|
||||||
functionname = casescript.get("FunctionName").toString();
|
functionname = casescript.get("FunctionName").toString();
|
||||||
//用例名称解析出现异常或是单个步骤参数解析异常
|
//用例名称解析出现异常或是单个步骤参数解析异常
|
||||||
|
|
|
@ -182,37 +182,6 @@ public class LogOperation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新本次任务的单条用例执行日志
|
|
||||||
*/
|
|
||||||
public static void updateCaseLogDetail(String caseno, String taskid, String detail, String loggrade, String step) {
|
|
||||||
try {
|
|
||||||
if (detail.indexOf("'") > -1) {
|
|
||||||
detail = detail.replaceAll("'", "''");
|
|
||||||
}
|
|
||||||
int inttaskid = Integer.parseInt(taskid);
|
|
||||||
String casesidsql;
|
|
||||||
casesidsql = dbt.executeQuery(
|
|
||||||
"select id from test_casedetail t where caseno = '" + caseno + "' and taskid = " + inttaskid);
|
|
||||||
int casesid = Integer.parseInt(casesidsql.substring(0, casesidsql.indexOf("%")));
|
|
||||||
|
|
||||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
String sql = "Insert into test_logdetail(LOGTIME,TASKID,CASEID,DETAIL,LOGGRADE,STEP,IMGNAME) "
|
|
||||||
+ "Values (str_to_date('" + df.format(new Date()) + "','%Y-%m-%d %T')," + inttaskid + "," + casesid
|
|
||||||
+ ",'" + detail + "','" + loggrade + "','" + step + "','')";
|
|
||||||
|
|
||||||
String re = dbt.executeSql(sql);
|
|
||||||
if (re.indexOf("成功") < 0) {
|
|
||||||
throw new Exception("更新用例:" + caseno + "步骤" + step + "日志到数据库中出现异常!!!");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
luckyclient.publicclass.LogUtil.APP.error("执行更新本次任务的单条用例执行日志SQL出现异常,请确认数据库链接是否正常!", e);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除单次任务指定的用例日志明细
|
* 删除单次任务指定的用例日志明细
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -25,25 +25,25 @@ public class MailSendInitialization {
|
||||||
if (taskCount.length == 5 && null != testJob) {
|
if (taskCount.length == 5 && null != testJob) {
|
||||||
Integer sendCondition = testJob.getSendCondition();
|
Integer sendCondition = testJob.getSendCondition();
|
||||||
// 用例全部成功了发送, casecount != casesuc
|
// 用例全部成功了发送, casecount != casesuc
|
||||||
if (1 == sendCondition) {
|
if (null!=sendCondition&&1 == sendCondition) {
|
||||||
if (taskCount[0] == taskCount[1]) {
|
if (taskCount[0] == taskCount[1]) {
|
||||||
isSend = true;
|
isSend = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 用例部分失败了发送
|
// 用例部分失败了发送
|
||||||
if (2 == sendCondition) {
|
if (null!=sendCondition&&2 == sendCondition) {
|
||||||
if (taskCount[2] > 0) {
|
if (taskCount[2] > 0) {
|
||||||
isSend = true;
|
isSend = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 全发
|
// 全发
|
||||||
if (0 == sendCondition) {
|
if (null!=sendCondition&&0 == sendCondition) {
|
||||||
isSend = true;
|
isSend = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!isSend) {
|
if (!isSend) {
|
||||||
luckyclient.publicclass.LogUtil.APP.info("当前任务不需要发送邮件通知! taskCount:" + taskCount);
|
luckyclient.publicclass.LogUtil.APP.info("当前任务不需要发送邮件通知!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String[] addresses = LogOperation.getEmailAddress(taskid);
|
String[] addresses = LogOperation.getEmailAddress(taskid);
|
||||||
|
|
Loading…
Reference in New Issue